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(); }
public ReportService(MISDbContext dbContext, ICompanyService companyService, IReceiptService receiptService) { this.dbContext = dbContext; this.companyService = companyService; this.receiptService = receiptService; }
public InvitationService(MISDbContext dbContext, ICompanyService companyService, IUserService userService) { this.dbContext = dbContext; this.companyService = companyService; this.userService = userService; }
public void Init() { var options = new DbContextOptionsBuilder <MISDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; this.dbContext = new MISDbContext(options); this.userService = new UserService(this.dbContext); }
public ReceiptService(MISDbContext dbContext, IUserService userService, ICompanyService companyService, IProductService productService) { this.dbContext = dbContext; this.userService = userService; this.companyService = companyService; this.productService = productService; }
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); }
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); }
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); }
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(); }
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); }
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; }
public RootAdminSeeder(UserManager <MISUser> userManager, MISDbContext context) { this.userManager = userManager; this.context = context; }
public MessageService(MISDbContext dbContext, ICompanyService companyService) { this.dbContext = dbContext; this.companyService = companyService; }
public ResultsController(MISDbContext context) { _context = context; }
public CategoryService(IWareHouseService wareHouseService, MISDbContext dbContext) { this.wareHouseService = wareHouseService; this.dbContext = dbContext; }
public LoginController(MISDbContext context,ILoginService login){ _login = login; _context = context; }//econ
//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; }
public CarCheckOutController(MISDbContext context) { _context = context; }
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; }
public CompanyService(MISDbContext dbContext, IUserService userService) { this.dbContext = dbContext; this.userService = userService; }
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); }
public ProductService(MISDbContext db, ICategoryService categoryService) { this.db = db; this.categoryService = categoryService; }
public WareHouseService(MISDbContext dbContext, ICompanyService companyService) { this.dbContext = dbContext; this.companyService = companyService; }
public UserService(MISDbContext dbContext) { this.dbContext = dbContext; }