コード例 #1
0
 public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, RoleManager <MyIdentityRole> roleManager, RolesDbContext db)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _roleManager   = roleManager;
     _db            = db;
 }
コード例 #2
0
ファイル: DatabaseContext.cs プロジェクト: AbhiAgarwal192/RBA
        public static void Initialize(RolesDbContext context)
        {
            context.ActionTypes.AddRange(new RBA.Data.Entities.ActionTypes
            {
                Id   = 1,
                Name = "READ"
            },
                                         new RBA.Data.Entities.ActionTypes
            {
                Id   = 2,
                Name = "WRITE"
            },
                                         new RBA.Data.Entities.ActionTypes
            {
                Id   = 3,
                Name = "DELETE"
            });

            context.Roles.Add(new RBA.Data.Entities.Roles {
                Id   = 1,
                Name = "Reader"
            });

            context.ActionTypeRoleMapping.Add(new RBA.Data.Entities.ActionTypeRoleMapping {
                ActionTypeId = 1,
                RoleId       = 1
            });

            context.Resource.Add(new RBA.Data.Entities.Resource {
                Id   = 1,
                Name = "/api/values"
            });

            context.ResourceRoleMapping.Add(new RBA.Data.Entities.ResourceRoleMapping {
                RoleId     = 1,
                ResourceId = 1
            });

            context.User.Add(new RBA.Data.Entities.User {
                Id   = 1,
                Name = "Abhi"
            });

            context.UserRolesMapping.Add(new RBA.Data.Entities.UserRolesMapping {
                UserId = 1,
                RoleId = 1
            });

            context.SaveChanges();
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: AbhiAgarwal192/RBA
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddLogging();

            var dbContextOptionsBuilder = new DbContextOptionsBuilder <RolesDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());

            services.AddDbContext <RolesDbContext>(options => options = dbContextOptionsBuilder);

            var rolesDBContext = new RolesDbContext(dbContextOptionsBuilder.Options);

            DatabaseContext.Initialize(rolesDBContext);

            services.AddTransient <IResourceRepository>(s => new ResourceRepository(rolesDBContext));
            services.AddTransient <IResourceRoleMappingRepository>(s => new ResourceRoleMappingRepository(rolesDBContext));
            services.AddTransient <IUserRepository>(s => new UserRepository(rolesDBContext));
            services.AddTransient <IUserRolesMappingRepository>(s => new UserRolesMappingRepository(rolesDBContext));
            services.AddTransient <IActionTypeRoleRepository>(s => new ActionTypeRoleRepository(rolesDBContext));
        }
コード例 #4
0
 public UserRolesMappingRepository(RolesDbContext rolesDbContext)
 {
     _rolesDbContext = rolesDbContext;
 }
コード例 #5
0
 public ResourceRoleMappingRepository(RolesDbContext rolesDbContext)
 {
     _rolesDbContext = rolesDbContext;
 }
コード例 #6
0
 public UsersRoleRepository(ApplicationDbContext db, RolesDbContext dbRole)
 {
     _db     = db;
     _dbRole = dbRole;
 }
コード例 #7
0
 public ActionTypeRoleRepository(RolesDbContext rolesDbContext)
 {
     _rolesDbContext = rolesDbContext;
 }