示例#1
0
        public async Task Init()
        {
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);
            var userService      = new UserService(this.dbContext);
            var companyService   = new CompanyService(this.dbContext, userService);
            var warehouseService = new WareHouseService(this.dbContext, companyService);
            var categoryService  = new CategoryService(warehouseService, this.dbContext);
            var productService   = new ProductService(this.dbContext, categoryService);

            this.receiptService = new ReceiptService(this.dbContext, userService, companyService, productService);


            var company = new Company()
            {
                Name    = "asd",
                Address = "asd",
            };

            await this.dbContext.AddAsync(company);

            await this.dbContext.SaveChangesAsync();

            var warehouse = new WareHouse()
            {
                Name    = "asd",
                Company = company,
            };

            var user = new MISUser()
            {
                UserName  = "******",
                Email     = "*****@*****.**",
                FirstName = "asdddd",
                Company   = company,
                LastName  = "asdddd",
            };


            await this.dbContext.AddAsync(warehouse);

            await this.dbContext.AddAsync(user);

            await this.dbContext.SaveChangesAsync();

            var category = new Category()
            {
                Name      = "asd",
                WareHouse = warehouse
            };


            await this.dbContext.AddAsync(category);

            await this.dbContext.SaveChangesAsync();
        }
示例#2
0
 public ReportService(MISDbContext dbContext,
                      ICompanyService companyService,
                      IReceiptService receiptService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
     this.receiptService = receiptService;
 }
示例#3
0
 public InvitationService(MISDbContext dbContext,
                          ICompanyService companyService,
                          IUserService userService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
     this.userService    = userService;
 }
示例#4
0
        public void Init()
        {
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            this.userService = new UserService(this.dbContext);
        }
示例#5
0
 public ReceiptService(MISDbContext dbContext,
                       IUserService userService,
                       ICompanyService companyService,
                       IProductService productService)
 {
     this.dbContext      = dbContext;
     this.userService    = userService;
     this.companyService = companyService;
     this.productService = productService;
 }
示例#6
0
        public async Task Init()
        {
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            var userService    = new UserService(this.dbContext);
            var companyService = new CompanyService(this.dbContext, userService);

            this.messagesService = new MessageService(this.dbContext, companyService);
        }
示例#7
0
        public void Init()
        {
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            var userService    = new UserService(this.dbContext);
            var companyService = new CompanyService(this.dbContext, userService);

            this.invitationService = new InvitationService(this.dbContext, companyService, userService);
        }
示例#8
0
        public async Task Init()
        {
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);
            var userService    = new UserService(this.dbContext);
            var companyService = new CompanyService(this.dbContext, userService);
            var company        = await companyService.CreateAsync(CompanyName, CompanyAddress);

            this.warehouseService = new WareHouseService(this.dbContext, companyService);
        }
示例#9
0
        public async Task Init()
        {
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            this.productService = new ProductService(this.dbContext,
                                                     new CategoryService(
                                                         new WareHouseService(this.dbContext,
                                                                              new CompanyService(this.dbContext, new UserService(this.dbContext))), this.dbContext));

            var company = new Company()
            {
                Name    = "asd",
                Address = "asd",
            };

            await this.dbContext.AddAsync(company);

            await this.dbContext.SaveChangesAsync();

            var warehouse = new WareHouse()
            {
                Name    = "asd",
                Company = company,
            };

            await this.dbContext.AddAsync(warehouse);

            await this.dbContext.SaveChangesAsync();

            var category = new Category()
            {
                Name      = "asd",
                WareHouse = warehouse
            };


            await this.dbContext.AddAsync(category);

            await this.dbContext.SaveChangesAsync();
        }
示例#10
0
        public async Task Init()
        {
            //TODO : REFACTOR
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            await this.dbContext.AddAsync(new MISUser()
            {
                UserName = "******",
                Company  = new Company
                {
                    Name     = "test",
                    Address  = "test",
                    Messages = new List <Message>()
                    {
                        new Message()
                        {
                            AddedOn  = DateTime.UtcNow,
                            Text     = "testMessage",
                            Username = "******"
                        },
                        new Message()
                        {
                            AddedOn  = DateTime.UtcNow,
                            Text     = "testMessage",
                            Username = "******"
                        }
                    },
                    WareHouses = new List <WareHouse>()
                    {
                        new WareHouse()
                        {
                            Name       = "testWareHouse",
                            IsFavorite = true,
                            Categories = new List <Category>()
                            {
                                new Category()
                                {
                                    Name     = "testCategoryName",
                                    Products = new List <Product>()
                                    {
                                        new Product()
                                        {
                                            Name     = "testProduct",
                                            BarCode  = "testBarcode",
                                            Price    = 2.4m,
                                            Quantity = 3,
                                        }
                                    }
                                }
                            }
                        }
                    },
                    Invitations = new List <Invitation>()
                    {
                        new Invitation()
                    }
                }
            });

            await this.dbContext.SaveChangesAsync();

            this.categoryService = new Mock <ICategoryService>().Object;
            this.productService  = new ProductService(this.dbContext, this.categoryService);
        }
示例#11
0
        public async Task Init()
        {
            //TODO : REFACTOR
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            await this.dbContext.AddAsync(new MISUser()
            {
                UserName = "******",
                Company  = new Company
                {
                    Name     = "test",
                    Address  = "test",
                    Messages = new List <Message>()
                    {
                        new Message()
                        {
                            AddedOn  = DateTime.UtcNow,
                            Text     = "testMessage",
                            Username = "******"
                        },
                        new Message()
                        {
                            AddedOn  = DateTime.UtcNow,
                            Text     = "testMessage",
                            Username = "******"
                        }
                    }
                }
            });

            await this.dbContext.SaveChangesAsync();

            var store = new Mock <IUserStore <MISUser> >();
            var mgr   = new Mock <UserManager <MISUser> >(store.Object, null, null, null, null, null, null, null, null);

            mgr.Object.UserValidators.Add(new UserValidator <MISUser>());
            mgr.Object.PasswordValidators.Add(new PasswordValidator <MISUser>());

            var signInManager = new Mock <SignInManager <MISUser> >(mgr.Object,
                                                                    new Mock <IHttpContextAccessor>().Object,
                                                                    new Mock <IUserClaimsPrincipalFactory <MISUser> >().Object,
                                                                    new Mock <IOptions <IdentityOptions> >().Object,
                                                                    new Mock <ILogger <SignInManager <MISUser> > >().Object,
                                                                    new Mock <IAuthenticationSchemeProvider>().Object);

            signInManager.Setup(x => x.SignOutAsync())
            .Returns(Task.CompletedTask);

            signInManager.Setup(x => x.SignInAsync(It.IsAny <MISUser>(), It.IsAny <bool>(), null))
            .Returns(Task.CompletedTask);

            mgr.Setup(x => x.GetUserAsync(It.IsAny <ClaimsPrincipal>()))
            .Returns((ClaimsPrincipal x) => this.dbContext.Users.FirstOrDefaultAsync(z => z.UserName == x.Identity.Name));

            var userService = new UserService(this.dbContext);

            this.companyService = new CompanyService(this.dbContext, userService);
            this.messageService = new MessageService(this.dbContext, this.companyService);
            this.userManager    = mgr.Object;
            this.signInManager  = signInManager.Object;
        }
示例#12
0
 public RootAdminSeeder(UserManager <MISUser> userManager, MISDbContext context)
 {
     this.userManager = userManager;
     this.context     = context;
 }
示例#13
0
 public MessageService(MISDbContext dbContext, ICompanyService companyService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
 }
示例#14
0
 public ResultsController(MISDbContext context)
 {
     _context = context;
 }
示例#15
0
 public CategoryService(IWareHouseService wareHouseService, MISDbContext dbContext)
 {
     this.wareHouseService = wareHouseService;
     this.dbContext        = dbContext;
 }
示例#16
0
 public LoginController(MISDbContext context,ILoginService login){
     _login      = login;
     _context    = context;
 }//econ
示例#17
0
 //step15: inject MISDbContext instance into the constructor
 public CartController(MISDbContext context){
     _context = context;  //step16: assign context instance to the field varaiable -> _context
 }//ec
 public ProductController(MISDbContext context)
 {
     _context = context;
 }
示例#19
0
 public CarCheckOutController(MISDbContext context)
 {
     _context = context;
 }
示例#20
0
        public async Task Init()
        {
            //TODO : REFACTOR
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            await this.dbContext.AddAsync(new MISUser()
            {
                UserName = "******",
                Company  = new Company
                {
                    Name     = "test",
                    Address  = "test",
                    Messages = new List <Message>()
                    {
                        new Message()
                        {
                            AddedOn  = DateTime.UtcNow,
                            Text     = "testMessage",
                            Username = "******"
                        },
                        new Message()
                        {
                            AddedOn  = DateTime.UtcNow,
                            Text     = "testMessage",
                            Username = "******"
                        }
                    },
                    WareHouses = new List <WareHouse>()
                    {
                        new WareHouse()
                        {
                            Name       = "testWareHouse",
                            IsFavorite = true,
                            Categories = new List <Category>()
                            {
                                new Category()
                                {
                                    Name = "testCategoryName",
                                }
                            }
                        }
                    }
                }
            });

            await this.dbContext.SaveChangesAsync();

            var store = new Mock <IUserStore <MISUser> >();
            var mgr   = new Mock <UserManager <MISUser> >(store.Object, null, null, null, null, null, null, null, null);

            mgr.Object.UserValidators.Add(new UserValidator <MISUser>());
            mgr.Object.PasswordValidators.Add(new PasswordValidator <MISUser>());

            mgr.Setup(x => x.GetUserAsync(It.IsAny <ClaimsPrincipal>()))
            .Returns((ClaimsPrincipal x) => this.dbContext.Users.FirstOrDefaultAsync(z => z.UserName == x.Identity.Name));

            this.categoryService = new CategoryService(new Mock <IWareHouseService>().Object, this.dbContext);
            this.userManager     = mgr.Object;
        }
示例#21
0
 public CompanyService(MISDbContext dbContext, IUserService userService)
 {
     this.dbContext   = dbContext;
     this.userService = userService;
 }
示例#22
0
        public async Task Init()
        {
            //TODO : REFACTOR
            var options = new DbContextOptionsBuilder <MISDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            this.dbContext = new MISDbContext(options);

            var product = new Product()
            {
                Name     = "testProduct",
                BarCode  = "testBarcode",
                Price    = 2.4m,
                Quantity = 3,
            };

            await this.dbContext.AddAsync(new MISUser()
            {
                UserName = "******",
                Company  = new Company
                {
                    Name       = "test",
                    Address    = "test",
                    WareHouses = new List <WareHouse>()
                    {
                        new WareHouse()
                        {
                            Name       = "testWareHouse",
                            IsFavorite = true,
                            Categories = new List <Category>()
                            {
                                new Category()
                                {
                                    Name     = "testCategoryName",
                                    Products = new List <Product>()
                                    {
                                        product
                                    }
                                }
                            },
                            Products = new List <Product>()
                            {
                                product
                            }
                        }
                    },
                },
                Receipts = new List <Receipt>()
                {
                    new Receipt()
                    {
                        IssuedOn = DateTime.UtcNow
                    },
                    new Receipt()
                },
                Reports = new List <Report>()
                {
                    new Report()
                    {
                        Name = "testReport",
                        From = DateTime.UtcNow.AddDays(-3),
                        To   = DateTime.UtcNow.AddDays(-3)
                    }
                }
            });

            await this.dbContext.SaveChangesAsync();


            var store = new Mock <IUserStore <MISUser> >();
            var mgr   = new Mock <UserManager <MISUser> >(store.Object, null, null, null, null, null, null, null, null);

            mgr.Object.UserValidators.Add(new UserValidator <MISUser>());
            mgr.Object.PasswordValidators.Add(new PasswordValidator <MISUser>());

            mgr.Setup(x => x.GetUserAsync(It.IsAny <ClaimsPrincipal>()))
            .Returns((ClaimsPrincipal x) => this.dbContext.Users.Include(c => c.Company).FirstOrDefaultAsync(z => z.UserName == x.Identity.Name));

            mgr.Setup(x => x.GetUserId(It.IsAny <ClaimsPrincipal>()))
            .Returns((ClaimsPrincipal x) => this.dbContext.Users.Include(c => c.Company).FirstOrDefaultAsync(z => z.UserName == x.Identity.Name).GetAwaiter().GetResult()?.Id);

            this.userManager = mgr.Object;

            var userService     = new UserService(this.dbContext);
            var companyService  = new CompanyService(this.dbContext, userService);
            var categoryService = new CategoryService(new WareHouseService(this.dbContext, companyService), this.dbContext);
            var productService  = new ProductService(this.dbContext, categoryService);
            var receiptService  = new ReceiptService(this.dbContext, userService, companyService, productService);

            this.reportService = new ReportService(this.dbContext, companyService, receiptService);
        }
示例#23
0
 public ProductService(MISDbContext db, ICategoryService categoryService)
 {
     this.db = db;
     this.categoryService = categoryService;
 }
示例#24
0
 public WareHouseService(MISDbContext dbContext, ICompanyService companyService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
 }
示例#25
0
 public UserService(MISDbContext dbContext)
 {
     this.dbContext = dbContext;
 }