Esempio n. 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();
        }
Esempio n. 2
0
 public ReportService(MISDbContext dbContext,
                      ICompanyService companyService,
                      IReceiptService receiptService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
     this.receiptService = receiptService;
 }
Esempio n. 3
0
 public InvitationService(MISDbContext dbContext,
                          ICompanyService companyService,
                          IUserService userService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
     this.userService    = userService;
 }
Esempio n. 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);
        }
Esempio n. 5
0
 public ReceiptService(MISDbContext dbContext,
                       IUserService userService,
                       ICompanyService companyService,
                       IProductService productService)
 {
     this.dbContext      = dbContext;
     this.userService    = userService;
     this.companyService = companyService;
     this.productService = productService;
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 12
0
 public RootAdminSeeder(UserManager <MISUser> userManager, MISDbContext context)
 {
     this.userManager = userManager;
     this.context     = context;
 }
Esempio n. 13
0
 public MessageService(MISDbContext dbContext, ICompanyService companyService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
 }
Esempio n. 14
0
 public ResultsController(MISDbContext context)
 {
     _context = context;
 }
Esempio n. 15
0
 public CategoryService(IWareHouseService wareHouseService, MISDbContext dbContext)
 {
     this.wareHouseService = wareHouseService;
     this.dbContext        = dbContext;
 }
Esempio n. 16
0
 public LoginController(MISDbContext context,ILoginService login){
     _login      = login;
     _context    = context;
 }//econ
Esempio n. 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
Esempio n. 18
0
 public ProductController(MISDbContext context)
 {
     _context = context;
 }
Esempio n. 19
0
 public CarCheckOutController(MISDbContext context)
 {
     _context = context;
 }
Esempio n. 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;
        }
Esempio n. 21
0
 public CompanyService(MISDbContext dbContext, IUserService userService)
 {
     this.dbContext   = dbContext;
     this.userService = userService;
 }
Esempio n. 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);
        }
Esempio n. 23
0
 public ProductService(MISDbContext db, ICategoryService categoryService)
 {
     this.db = db;
     this.categoryService = categoryService;
 }
Esempio n. 24
0
 public WareHouseService(MISDbContext dbContext, ICompanyService companyService)
 {
     this.dbContext      = dbContext;
     this.companyService = companyService;
 }
Esempio n. 25
0
 public UserService(MISDbContext dbContext)
 {
     this.dbContext = dbContext;
 }