Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Module plugin : Roles and Permissions #2689


User avatar
0
ivanosw1 created

Hi, I've developed a plugin module that is successfully loaded by Abp. (dotnetcore) I made a different dbcontext and I can use IRepository<myentity> and also IRepository<RolePermisionSetting>, but I'm unable to use IRepository<Role> . There is alway an error of DI. How can I use in my outer module all the security/admin stuff of abp.zero ?

Thanks


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share your DbContext definition ?

    Thanks.

  • User Avatar
    0
    ivanosw1 created

    Shure, it's very simple. Only one table CuwPermission. I wuold like to use IRepository<Role>, IRepository<User>, and so on.

    public class CartellaUtenteWebContext: AbpDbContext { public virtual DbSet<CuwPermission> CuwPermissions { get; set; }

        /* Default constructor is needed for EF command line tool. */
        public CartellaUtenteWebContext()
            : base(GetConnectionString())
        {
    
        }
    

    .... omitted ctors code

    DomainService where I need Role Repository:

    public class CuwRoleDomainService: DomainService, ICuwRoleDomainService { private readonly IRepository<Role> roleRepository; public CuwRoleDomainService(IRepository<Role> roleRepository) { this.roleRepository = roleRepository; }

        public async Task&lt;Role&gt; GetRoleAsync(int roleId)
        {
            var result = await roleRepository.FirstOrDefaultAsync(roleId);
            return result;
        }
    }
    

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Your DbContext seems fine. Normally User and Role entities are defined in your Core module, did you add a reference to core module to your plugin module ?

  • User Avatar
    0
    ivanosw1 created

    Hi,

    The module is outside of abpzero template solution (host). The scenario is that many developers build their own plugins and at the end all plugins are deployed on a remote server. Nobody can access to the host solutions.

    I've resolved in this manner :

    • created a nuget package from abpzero core module.
    • referenced this package on our core plugin module
    • set DependsOn to abpzero core module

    It seems to work fine and when you improve abpzero template, we need only to upgrade the nuget package.

    Do you think is a correct way ?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This is the best solution at the moment I think :).