コード例 #1
0
 /// <summary>
 /// CONSTRUCTOR CONTROLLER.
 /// </summary>
 /// <param name="userManager">USER MANAGER SERVICE.</param>
 public UsersController(UserManager <User> userManager,
                        RoleManager <IdentityRole> roleManager,
                        KnowledgeSpaceContext context)
 {
     _userManager = userManager;
     _roleManager = roleManager;
     _context     = context;
 }
コード例 #2
0
        public KnowledgeSpaceContext GetApplicationDbContext()
        {
            var options = new DbContextOptionsBuilder <KnowledgeSpaceContext>()
                          .UseInMemoryDatabase(databaseName: "InMemoryApplicationDatabase")
                          .Options;
            var dbContext = new KnowledgeSpaceContext(options);

            return(dbContext);
        }
コード例 #3
0
 /// <summary>
 /// CONSTRUCTOR CONTROLLER.
 /// </summary>
 /// <param name="context">DbContext.</param>
 public KnowledgeBasesController(KnowledgeSpaceContext context,
                                 ISequenceService sequenceService,
                                 IStorageService storageService,
                                 ICacheService cacheService)
 {
     _context         = context;
     _sequenceService = sequenceService;
     _storageService  = storageService;
     _cacheService    = cacheService;
 }
コード例 #4
0
 public IdentityProfileService(IUserClaimsPrincipalFactory <User> claimsFactory,
                               UserManager <User> userManager,
                               KnowledgeSpaceContext context,
                               RoleManager <IdentityRole> roleManager)
 {
     _claimsFactory = claimsFactory;
     _userManager   = userManager;
     _context       = context;
     _roleManager   = roleManager;
 }
コード例 #5
0
        /// <summary>
        /// CONSTRUCTOR TEST.
        /// </summary>
        public UsersControllerTest()
        {
            var userStore = new Mock <IUserStore <User> >();

            _mockUserManager = new Mock <UserManager <User> >(userStore.Object,
                                                              null, null, null, null, null, null, null, null);

            var roleStore = new Mock <IRoleStore <IdentityRole> >();

            _mockRoleManager = new Mock <RoleManager <IdentityRole> >(roleStore.Object, null, null, null, null);

            _context = new InMemoryDbContextFactory().GetApplicationDbContext();
        }
コード例 #6
0
        /// <summary>
        /// CONSTRUCTOR TEST.
        /// </summary>
        public RolesControllerTest()
        {
            var roleStore = new Mock <IRoleStore <IdentityRole> >();

            _mockRoleManager = new Mock <RoleManager <IdentityRole> >(roleStore.Object, null, null, null, null);

            _context = new InMemoryDbContextFactory().GetApplicationDbContext();

            _roleSources = new List <IdentityRole>()
            {
                new IdentityRole("test1"),
                new IdentityRole("test2"),
                new IdentityRole("test3"),
                new IdentityRole("test4")
            };
        }
コード例 #7
0
 public LabelsController(KnowledgeSpaceContext context)
 {
     _context = context;
 }
コード例 #8
0
 public StatisticsController(KnowledgeSpaceContext context)
 {
     _context = context;
 }
コード例 #9
0
        public CommandInFunctionControllerTest()
        {
            _context = new InMemoryDbContextFactory().GetApplicationDbContext();

            _context.Functions.AddRange(new List <Function>()
            {
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess1",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess1",
                    SortOrder = 1,
                    Url       = "/test1"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess2",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess2",
                    SortOrder = 2,
                    Url       = "/test2"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess3",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess3",
                    SortOrder = 3,
                    Url       = "/test3"
                },
                new Function()
                {
                    Id        = "GetFunctionsPaging_NoFilter_ReturnSuccess4",
                    ParentId  = null,
                    Name      = "GetFunctionsPaging_NoFilter_ReturnSuccess4",
                    SortOrder = 4,
                    Url       = "/test4"
                }
            });
            _context.SaveChangesAsync();

            _context.Commands.AddRange(new List <Command>()
            {
                new Command()
                {
                    Id = "TEST1", Name = "Xem"
                },
                new Command()
                {
                    Id = "TEST2", Name = "Thêm"
                },
                new Command()
                {
                    Id = "TEST3", Name = "Sửa"
                },
                new Command()
                {
                    Id = "TEST4", Name = "Xoá"
                },
                new Command()
                {
                    Id = "TEST5", Name = "Duyệt"
                },
            });

            var functions = _context.Functions;

            if (!_context.CommandInFunctions.Any())
            {
                foreach (var function in functions)
                {
                    var createAction = new CommandInFunction()
                    {
                        CommandId  = "TEST2",
                        FunctionId = function.Id
                    };
                    _context.CommandInFunctions.Add(createAction);

                    var updateAction = new CommandInFunction()
                    {
                        CommandId  = "TEST3",
                        FunctionId = function.Id
                    };
                    _context.CommandInFunctions.Add(updateAction);
                    var deleteAction = new CommandInFunction()
                    {
                        CommandId  = "TEST4",
                        FunctionId = function.Id
                    };
                    _context.CommandInFunctions.Add(deleteAction);

                    var viewAction = new CommandInFunction()
                    {
                        CommandId  = "TEST1",
                        FunctionId = function.Id
                    };
                    _context.CommandInFunctions.Add(viewAction);
                }
            }

            _context.SaveChangesAsync();
        }
コード例 #10
0
 /// <summary>
 /// CONSTRUCTOR CONTROLLER.
 /// </summary>
 /// <param name="context"></param>
 public CategoriesController(KnowledgeSpaceContext context,
                             ICacheService cacheService)
 {
     _context      = context;
     _cacheService = cacheService;
 }
コード例 #11
0
 /// <summary>
 /// CONSTRUCTOR CONTROLLER.
 /// </summary>
 /// <param name="context">DbContext.</param>
 public FunctionsController(KnowledgeSpaceContext context)
 {
     _context = context;
 }
コード例 #12
0
 public FunctionsControllerTest()
 {
     _context = new InMemoryDbContextFactory().GetApplicationDbContext();
 }
コード例 #13
0
 /// <summary>
 /// CONSTRUCTOR CONTROLLER.
 /// </summary>
 /// <param name="roleManager">ROLE MANAGER SERVICE.</param>
 public RolesController(RoleManager <IdentityRole> roleManager,
                        KnowledgeSpaceContext context)
 {
     _roleManger = roleManager;
     _context    = context;
 }
コード例 #14
0
 /// <summary>
 /// CONSTRUCTOR CONTROLLER.
 /// </summary>
 /// <param name="context">DbContext.</param>
 public CommandsController(KnowledgeSpaceContext context)
 {
     _context = context;
 }