Base solution for your next web application

Activities of "cicciottino"

i'm trying to install module zero from scratch

i've followed the documentation: <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Zero/installation#DocInstallManual">http://aspnetboilerplate.com/Pages/Docu ... tallManual</a>

till this point... i can't see this method

internal sealed class Configuration : DbMigrationsConfiguration<AbpZeroSample.EntityFramework.AbpZeroSampleDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
        ContextKey = "AbpZeroSample";
    }

    protected override void Seed(AbpZeroSample.EntityFramework.AbpZeroSampleDbContext context)
    {
        context.DisableAllFilters();   //<--- it seems not existing ????
        new DefaultTenantRoleAndUserBuilder(context).Build();
    }
}

xxx.DisableAllFilters(); where is implemented?

"AbpZeroSampleDbContext" implements "AbpZeroDbContext" where i supposed to found the method (or in its own derivated classes)

Good!

Question

i'm trying to install ModuleZero from scrath following the link: <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Zero/installation#DocInstallManual">http://aspnetboilerplate.com/Pages/Docu ... tallManual</a>

in the Login(POST)method of AccountController i got an error

[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(    //<--HERE IS WHERE I GOT THE ERROR
                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 });
        }

the error is only visible with the browser tool(F12-->network)

Multiple object sets per type are not supported. The object sets 'Roles' and 'Roles' can both contain instances of type 'ModuleZeroFromScratch.Authorization.Roles.Role'

so (as you suggest me in the past) i placed the class

public class MyExceptionHandler : IEventHandler<AbpHandledExceptionData>, ITransientDependency
    {
        public void HandleEvent(AbpHandledExceptionData eventData)
        {
            //TODO: Check eventData.Exception!
        }
    }

into the web project but nothing. Again, i put this class in the "Core" module (where the source of error is, "UserManager") but nothing.

the questions are:

  1. putting this class in the Web project(the outermost) does it catch exceptions occurred in every module? or only in the module where such a class is present? If it is the first why this does not happen?

  2. do you have an idea from the message what is the problem or at least what i should check?

Answer

you're right i've duplicated the DbSet's

so now i got this error on the Account/Login

There should be a 'Default' tenant if multi-tenancy is disabled!

where i should provide this default value? in the model? in the seed method? directly into the db?

is it possible to pass a normal string istead of a LocalizableString into the "DisplayName" parameter of the (MenuItemDefinition)NavigationProvider? if not, is there a sort of workaround?

public override void SetNavigation(INavigationProviderContext context)
{
context.Manager.MainMenu
                .AddItem(
                    new MenuItemDefinition(
                        "Home",
                        new LocalizableString("HomePage", AbpZeroSampleConsts.LocalizationSourceName),
                        url: "#/",
                        icon: "fa fa-home"
                        )
                ).AddItem(
                    new MenuItemDefinition(
                        "About",
                        new LocalizableString("PoisList", AbpZeroSampleConsts.LocalizationSourceName),  //using a normal string instead of LocalizationString
                        url: "#/About",
                        icon: "fa fa-info"
                        );

thanks a lot, i didn't know the existance of this class!

applying some ".where(x=>....)" condition in the repository the filter is not applied (i verified this with the sqlprofiler as well)

my ApplicationService (PoiAppService):

public class PoiAppService : ApplicationService, IPoiAppService
    {
        private readonly IPoiRepository _poiRepository;
        
        public PoiAppService(IPoiRepository poiRepository)
        {
            _poiRepository = poiRepository;
        }


        public GetPoisOutput GetPois(GetPoisInput input)
        {
            var pois = _poiRepository.GetAllPois(input.State, null);

            return new GetPoisOutput
            {
                Pois = Mapper.Map<List<PoiDto>>(pois)
            };
        }
    }
}

my repository (PoiRepository)

public class PoiRepository : AbpZeroSampleRepositoryBase<Poi,long>, IPoiRepository
    {
        public PoiRepository(IDbContextProvider<AbpZeroSampleDbContext> dbContextProvider)
            : base(dbContextProvider)
        { 
        }


        public List<Poi> GetAllPois(PoiState poistate, PoiType poitype)   //PoiType is not used yet
        {
            var query = GetAll();

            if (poistate == PoiState.NotVerified)
                query.Where(x => x.ValidationRate == 0);      //<--this seems not applied
            if (poistate == PoiState.Verified)
                query.Where(x => x.ValidationRate > 0);	      //<--this seems not applied

            return query.OrderByDescending(x => x.Name).ToList(); 
        }

    }

debugging the code i've noticed that the execution of both (applicationService method and repository method) happens twice. And i've verified with the browser tool that the call to the service happened once! why? the execution passes two times in the same code? anyway the .where condition on the query is never applied (as sqlprofiles has showed me)

so i've simplified my repo(se below) to restrict the research field but the problem

persist. the strange thing is that the execution is repeted twice (like in async way)

my ApplicationService (PoiAppService):

public class PoiAppService : ApplicationService, IPoiAppService
    {
        private readonly IPoiRepository _poiRepository;

        public PoiAppService(IPoiRepository poiRepository)
        {
            _poiRepository = poiRepository;
        }

        public GetPoisOutput GetPois()
        {
            var pois = _poiRepository.GetAllPois();
            
            return new GetPoisOutput
            {
                Pois = Mapper.Map<List<PoiDto>>(pois)
            };
        }

    }

my repository (PoiRepository)

public class PoiRepository : AbpZeroSampleRepositoryBase<Poi, long>, IPoiRepository
    {
        public PoiRepository(IDbContextProvider<AbpZeroSampleDbContext> dbContextProvider)
            : base(dbContextProvider)
        { 
        }

        public List<Poi> GetAllPois()
        {
            var query = GetAll();
            query.Where(x=>x.Id == 91);  //an existing id, just to test
            
            return query.OrderByDescending(x => x.Name).ToList(); 
        }
    }

i've notice also that: in the browser's developer tool, the script "GetAll.js" is

downloaded 2 times, sholud it be unique, really? In an old example project "SimpleTaskProject" i see only one "GetAll.js" (the only

difference is that my project has ModuleZero installed (from the template) is this script generated on applicationLayer basis? how can i investigate deeply?

see the image

thanks a lot, here is my project ready to download (with migrations and seed data) [http://www.filedropper.com/fromtemplate])

Are there in your example projects some part that uses the javascript function(the ajax

calls to the services) made for jquery instead of angular? if yes, where? thank 1000 for you kind and active cooperation

Alessio

Stupid me :roll: Thanks

Showing 11 to 20 of 42 entries