Base solution for your next web application

Activities of "codemonkey21"

I restarted my project on a fresh core template (v 1.4.2 at the time of download). It appears that that it should in theory write logs out of the box, however no log file has been generated. I've attemped to manually write to the log calling the Logger in an app service and that also does not generate any results. Now that I need to debug, I desperately need the log file.

I even tried to manually create a default blank logs.txt file.

project.web references are; abp.castle.log4net (1.4.2) castle.loggingfacility.mslogging (1.1.0)

From project.web startup.cs

public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //MVC
            services.AddMvc(options =>
            {
                options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            });

            //Configure Abp and Dependency Injection
            return services.AddAbp<NyxlyWebModule>(options =>
            {
                //Configure Log4Net logging
                options.IocManager.IocContainer.AddFacility<LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                );
            });
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            app.UseAbp(); //Initializes ABP framework.

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            AuthConfigurer.Configure(app, _appConfiguration);

            app.UseStaticFiles();

            //Integrate to OWIN
            app.UseAppBuilder(ConfigureOwinServices);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "defaultWithArea",
                    template: "{area}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseMiddleware<BeginRequest>(env);
        }

from log4net.config

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
    <file value="App_Data/Logs/Logs.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="10000KB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%-5level %date [%-5.5thread] %-40.40logger - %message%newline" />
    </layout>
  </appender>
  <root>
    <appender-ref ref="RollingFileAppender" />
    <level value="DEBUG" />
  </root>
  <logger name="NHibernate">
    <level value="WARN" />
  </logger>
</log4net>
Question

I'm trying to figure out where to assign my web users. I want my site to have several types of users. Think of Yelp.

End users: Every day people signing up and using the site to browse, connect, add venues, write reviews, etc. Business users: Register a business (tenant) and then claim their venue/business.

Should be end user be a host user or a default tenant user? These users search the site for venues and write reviews about them. If the venue does not exist, they can add the venue. A venue entity has the IMayHaveTenant interface. This then throws an exception because my end user is current a Default (tenant id 1) user but the venue has a null tenant id. So there is a mis-match.

When a business claims a venue, the venue then gets a tenant id for that business. Is that going to stop host/default users from viewing and writing reviews on a claimed business?

I guess my question is, should a newly created venue be a host tenant of null or the default tenant of 1 since that's what my end users are. Or do I toss out the interface on the venue entity and skip the data filter. I can create an alternate method to claim a business. Or do my end users all need to be host users?

Sorry that was like six questions. :)

This question is more of a best practice than a code question. It's related to complex or nested entities and if you need a separate service class for each entity or if you should put related managers and methods in the parent/master entity service class? Let me give you some examples;

User: Entity (Parent object) UserImage: Entity (collection) UserCheckIn:Entity (collection) UserActivity:Entity (collection) UserPoints:Entity (collection) Review:Entity (collection)

A user has a collection of images, checkings, activities, points, etc. I know I should create a UserImageManager at the domain level in the Core project, but would you create a UserImageAppService OR put it in the UserAppService since it relates to the User object owns it.

Venue:Entity (Parent object) Review:Entity (collection) ReviewRating:Entity (collection)

Second example. A venue has reviews, reviews have ratings (helpful, not helpful). Would you create a separate ReviewAppService or add a method to the VenueAppService with a ReviewManager reference like _reviewManager.AddReviewToVenue(CreateReviewInput input) since ultimately a review can only belong to one venue.

Just wanted to put out the question and see what other people are doing or how Halil thinks it should work. Most of the examples / samples are too simple compared to real world to figure out best practice.

Thanks!

All the icons in the navigation provider appear to use Font Awesome. Does this allow the use of a custom icon? If so, how?

<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Navigation">http://www.aspnetboilerplate.com/Pages/ ... Navigation</a>

I created my project as a MPA site, then added in Zero following the instructions here: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Installation">http://www.aspnetboilerplate.com/Pages/ ... stallation</a>

Ran all appropriate migrations and seed methods.

I then created an AngularJS admin app. I created a UserAppService with GetUsers() and tested in the console like demoed here: <a class="postlink" href="http://www.aspnetzero.com/Documents/Developing-Step-By-Step#testing-personappservice-from-browser-console">http://www.aspnetzero.com/Documents/Dev ... er-console</a>

This is where I first got the error for MustHaveTenant. So I assumed it was because I wasn't logging in. I went to the login form and on the LoginAsync method, I get the "Filter name MustHaveTenant not Found" exception when the method _userManager.LoginAsync() runs and trying to login as 'admin' / '123qwe'.

I've read every document 10x now and cannot figure out why this happening.

[HttpPost]
        public async Task<JsonResult> Login(LoginViewModel loginModel, string returnUrl = "")
        {
            if (!ModelState.IsValid)
            {
                throw new UserFriendlyException("Your form is invalid!");
            }

                var loginResult = await _userManager.LoginAsync(
                    loginModel.UsernameOrEmailAddress,
                    loginModel.Password,
                    loginModel.TenancyName
                    );

                switch (loginResult.Result)
                {
                    case AbpLoginResultType.Success:
                        break;
                    case AbpLoginResultType.InvalidUserNameOrEmailAddress:
                    case AbpLoginResultType.InvalidPassword:
                        throw new UserFriendlyException("Invalid user name or password!");
                    case AbpLoginResultType.InvalidTenancyName:
                        throw new UserFriendlyException("No tenant with name: " + loginModel.TenancyName);
                    case AbpLoginResultType.TenantIsNotActive:
                        throw new UserFriendlyException("Tenant is not active: " + loginModel.TenancyName);
                    case AbpLoginResultType.UserIsNotActive:
                        throw new UserFriendlyException("User is not active: " + loginModel.UsernameOrEmailAddress);
                    case AbpLoginResultType.UserEmailIsNotConfirmed:
                        throw new UserFriendlyException("Your email address is not confirmed!");
                    default: //Can not fall to default for now. But other result types can be added in the future and we may forget to handle it
                        throw new UserFriendlyException("Unknown problem with login: " + loginResult.Result);
                }

                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
                AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = loginModel.RememberMe }, loginResult.Identity);


            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }

            return Json(new MvcAjaxResponse { TargetUrl = returnUrl });
        }
Showing 1 to 5 of 5 entries