public static async Task SeedUserActivityStatusFilters(GearContext context) { if (!await context.UserActivityStatusFilters.AnyAsync()) { var activityStatuses = new List <ActivityStatus> { ActivityStatus.New, ActivityStatus.InProgress, ActivityStatus.Refused, ActivityStatus.Developed, ActivityStatus.Tested, ActivityStatus.Completed }; var employees = await context.ApplicationUsers.ToListAsync(); var reports = await context.Reports.ToListAsync(); var activityStatusFilters = (from employee in employees from report in reports from activityStatus in activityStatuses select new UserActivityStatusFilter <Guid> { Id = Guid.NewGuid(), ReportId = report.Id, UserId = employee.Id, ActivityStatus = activityStatus }) .ToList(); await context.UserActivityStatusFilters.AddRangeAsync(activityStatusFilters); await context.SaveChangesAsync(); } }
public static async Task SeedUserProjectStatusFilters(GearContext context) { if (!await context.UserProjectStatusFilters.AnyAsync()) { var projectStatuses = new List <ProjectStatus> { ProjectStatus.New, ProjectStatus.InProgress, ProjectStatus.OnHold, ProjectStatus.Canceled, ProjectStatus.Completed }; var reports = await context.Reports.ToListAsync(); var users = await context.ApplicationUsers.ToListAsync(); var projectStatusFilters = (from report in reports from user in users from projectStatus in projectStatuses select new UserProjectStatusFilter <Guid> { Id = Guid.NewGuid(), UserId = user.Id, ReportId = report.Id, ProjectStatus = projectStatus }) .ToList(); await context.UserProjectStatusFilters.AddRangeAsync(projectStatusFilters); await context.SaveChangesAsync(); } }
public static async Task SeedReportNotificationServices(GearContext context) { if (!await context.ServiceTimeCheckers.AnyAsync()) { await context.ServiceTimeCheckers.AddRangeAsync(new List <ServiceTimeChecker> { new ServiceTimeChecker { ServiceId = Guid.NewGuid(), ServiceName = "OverdueAdm", ExecutedLastTime = null }, new ServiceTimeChecker { ServiceId = Guid.NewGuid(), ServiceName = "OverduePm", ExecutedLastTime = null }, new ServiceTimeChecker { ServiceId = Guid.NewGuid(), ServiceName = "DailyLogsAdm", ExecutedLastTime = null }, new ServiceTimeChecker { ServiceId = Guid.NewGuid(), ServiceName = "DailyLogsPm", ExecutedLastTime = null }, new ServiceTimeChecker { ServiceId = Guid.NewGuid(), ServiceName = "YesterdayLogsAdm", ExecutedLastTime = null }, new ServiceTimeChecker { ServiceId = Guid.NewGuid(), ServiceName = "YesterdayLogsPm", ExecutedLastTime = null } }); await context.SaveChangesAsync(); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, GearContext context, UserManager <ApplicationUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseStatusCodePagesWithReExecute("/error", "?statusCode={0}"); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action}/{id?}"); }); }
public static async Task SeedUserDateFilters(GearContext context) { // The Due date currently is omitted intentionally. if (!await context.UserDateFilters.AnyAsync()) { var employees = await context.ApplicationUsers.ToListAsync(); var reports = await context.Reports.ToListAsync(); var userDateFilters = (from employe in employees from report in reports select new UserDateFilter <Guid> { Id = Guid.NewGuid(), UserId = employe.Id, FilterType = FilterType.StartDate, ReportId = report.Id, Date = DateTime.Now.AddYears(-1) }).ToList(); await context.UserDateFilters.AddRangeAsync(userDateFilters); await context.SaveChangesAsync(); } }
public async Task Seed(GearContext context, UserManager <ApplicationUser> userManager) { if (context != null) { await SeedReports(context); await SeedHeaders(context); await SeedReportHeader(context); await SeedUserReports(context); await SeedAllowedFilters(context); await SeedUserProjectStatusFilters(context); await SeedUserActivityStatusFilters(context); await SeedUserDateFilters(context); await SeedUserGuidFilters(context, userManager); await SeedReportNotificationServices(context); } }
public OrderController(GearContext context, IOrderItemRepository item, IOrderRepository order, ICartItemRepository cart, IProductRepository product) { _context = context; _item = item; _order = order; _cart = cart; _product = product; }
public void Seed(GearContext context, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager) { context.Database.EnsureCreated(); SeedUsers(context, userManager); SeedPlatforms(context); SeedProjectGroups(context, userManager); SeedDepartments(context, userManager); SeedBusinessUnits(context, userManager); }
public void SeedProjectGroups(GearContext context, UserManager <ApplicationUser> userManager) { if (!context.ProjectGroups.Any(pg => pg.Name == "Uncategorized")) { var user = userManager.FindByEmailAsync("*****@*****.**").Result; var defaultProjectGroup = new ProjectGroup { IsDeletable = false }; defaultProjectGroup.CreateEnd(Guid.NewGuid(), "Uncategorized", user.Id); context.ProjectGroups.Add(defaultProjectGroup); context.SaveChanges(); } }
public void SeedDepartments(GearContext context, UserManager <ApplicationUser> userManager) { if (context.Departments.Any(u => !u.IsDeletable)) { return; } var user = userManager.FindByEmailAsync("*****@*****.**").Result; var invisibleDepartment = new Department { IsDeletable = false, }; invisibleDepartment.CreateEnd(Guid.NewGuid(), "NotDeletable", user.Id); context.Departments.Add(invisibleDepartment); context.SaveChanges(); }
public void SeedBusinessUnits(GearContext context, UserManager <ApplicationUser> userManager) { if (context.BusinessUnits.Any(u => !u.IsDeletable)) { return; } var user = userManager.FindByEmailAsync("*****@*****.**").Result; var invisibleBusinessUnit = new BusinessUnit { IsDeletable = false }; invisibleBusinessUnit.CreateEnd(Guid.NewGuid(), "Uncategorized", user.Id); context.BusinessUnits.Add(invisibleBusinessUnit); context.SaveChanges(); }
public static async Task SeedReports(GearContext context) { if (!await context.Reports.AnyAsync()) { await context.Reports.AddRangeAsync(new List <Report <Guid> > { new Report <Guid> { Id = Guid.NewGuid(), Name = "Employee logged time" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Employee logged time by period" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Project general" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Project group list" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Activity lists" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Sprint list" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Projects by filters" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Teams by filters" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Project groups by filters" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "General filtered" }, new Report <Guid> { Id = Guid.NewGuid(), Name = "Overdue" } }); await context.SaveChangesAsync(); } }
public void SeedPlatforms(GearContext context) { context.Instance.Set <Platform>().AddIfNotExists(new Platform() { Name = "CRM" }); context.Instance.Set <Platform>().AddIfNotExists(new Platform() { Name = "PM" }); context.Instance.Set <Platform>().AddIfNotExists(new Platform() { Name = "HRM" }); context.SaveChanges(); }
public static async Task SeedAllowedFilters(GearContext context) { if (!await context.ReportFilters.AnyAsync()) { var employees = await context.ApplicationUsers.ToListAsync(); var reports = await context.Reports.ToListAsync(); var filters = new List <FilterType> { FilterType.Guid, FilterType.StartDate, FilterType.DueDate, FilterType.ActivityStatus, FilterType.ProjectStatus, FilterType.ProjectGroupIds, FilterType.ProjectIds, FilterType.ActivityListIds, FilterType.SprintIds, FilterType.ActivityIds, FilterType.ActivityTypeIds, FilterType.EmployeeIds, }; var reportFilters = (from employee in employees from report in reports from filterType in filters.Distinct() select new ReportFilter <Guid> { Active = true, ReportId = report.Id, UserId = employee.Id, FilterType = filterType }) .ToList(); await context.ReportFilters.AddRangeAsync(reportFilters.Distinct()); await context.SaveChangesAsync(); } }
public static async Task SeedUserReports(GearContext context) { if (!await context.UserReports.AnyAsync()) { var employees = await context.ApplicationUsers.ToListAsync(); var reports = await context.Reports.ToListAsync(); var userReports = (from employee in employees from report in reports select new UserReport <Guid> { ReportId = report.Id, UserId = employee.Id }).ToList(); await context.AddRangeAsync(userReports); await context.SaveChangesAsync(); } }
public void SeedUsers(GearContext context, UserManager <ApplicationUser> userManager) { if (!context.Users.Any(u => u.UserName == "*****@*****.**")) { var admin = new ApplicationUser { FirstName = "Admin", LastName = "Indrivo", UserName = "******", NormalizedUserName = "******", Email = "*****@*****.**", NormalizedEmail = "*****@*****.**" }; var result = userManager.CreateAsync(admin, "@dminPass1").Result; if (!result.Succeeded) { throw new Exception($"Default user {admin.UserName} cannot be created."); } } }
public static async Task SeedReportHeader(GearContext context) { if (!await context.ReportTableHeaders.AnyAsync()) { var reports = await context.Reports.ToListAsync(); var employees = await context.ApplicationUsers.ToListAsync(); var tableHeaders = await context.TableHeaders.ToListAsync(); var reportTableHeaders = (from report in reports from employee in employees from header in tableHeaders select new ReportTableHeader <Guid> { UserId = employee.Id, ReportId = report.Id, TableHeaderId = header.Id, Active = true, }).ToList(); await context.ReportTableHeaders.AddRangeAsync(reportTableHeaders); await context.SaveChangesAsync(); } }
public CartsController(GearContext context, ICartItemRepository cartRepository) { _context = context; _cartRepository = cartRepository; }
public ProducerRepository(GearContext context) { _context = context; }
public ProductController(GearContext context, IProductRepository products, IWebHostEnvironment env) { _context = context; _products = products; _env = env; }
public CPUController(GearContext gearContext, IHostingEnvironment environment) { _gearContext = gearContext; _environment = environment; }
public UserController(GearContext userContext) { _userContext = userContext; }
public static async Task SeedCatalog(GearContext context) { context.Database.EnsureCreated(); if (!context.Catalogs.Any()) { var catalogs = new List <Catalog> { new Catalog { Name = "Chuột", Description = "Các sản phẩm liên quan đến chuột: chuột chơi game, chuột văn phòng" }, new Catalog { Name = "Bàn Phím", Description = "Các sản phẩm bàn phím như bàn phím cơ, bàn phím văn phòng,..." }, new Catalog { Name = "Tai nghe", Description = "Nhiều thể loại tai nghe từ tai nghe gaming đến tai nghe chuyên về nghe nhạc" }, }; await context.Catalogs.AddRangeAsync(catalogs); await context.SaveChangesAsync(); } if (!context.Producers.Any()) { var producers = new List <Producer> { new Producer { Name = "MSI", Description = "Một hãng nổi tiếng chuyên về các thể loại chuột, laptop gaming,..." }, new Producer { Name = "Logitech", Description = "Được biết là một hãng với các thiết bị gaming đạt chất lượng toàn cầu" }, new Producer { Name = "Sony", Description = "Hãng với nhiều thiết bị công nghệ đình đám của Nhật Bản" }, }; await context.Producers.AddRangeAsync(producers); await context.SaveChangesAsync(); } if (!context.Products.Any()) { var products = new List <Product> { new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "<div>Hello</div>", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1, ProducerID = 1, Stock = 20, Slug = "product-1" }, new Product { Name = "Product 2222222", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4800000, Discount = 30, PriceDiscount = 299999, CatalogID = 1, ProducerID = 1, Stock = 20, Slug = "product-2" }, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 1, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 5, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 1, CatalogID = 2,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 9, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 2,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 3, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 2,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 2,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 2,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, // new Product { Name = "Product 1", Image = "aqua.jpg", SubImage = "aqua.jpg", Description = "abc", Price = 4300000, Discount = 30, PriceDiscount = 299999, CatalogID = 1,ProducerID = 1, Stock = 20, Slug = "product-1"}, }; await context.Products.AddRangeAsync(products); await context.SaveChangesAsync(); } if (!context.CartItems.Any()) { var cartItems = new List <CartItem> { new CartItem { UserId = "100", Product = context.Products.FirstOrDefault(), Quantity = 1 } }; await context.CartItems.AddRangeAsync(cartItems); await context.SaveChangesAsync(); } if (!context.Orders.Any()) { var orders = new List <Order> { new Order { OrderId = "100", ShippingAddress = "aaa", ShippingPhone = "aaaa", ShippingReciver = "aaa", UserId = "f2de0d50-9fd5-45b3-aa4f-923b843f8b5d", CreateDT = DateTime.UtcNow.AddHours(7), TotalPrice = context.Products.FirstOrDefault().PriceDiscount, OrderStatus = "Đang giao" }, new Order { OrderId = "101", ShippingAddress = "aaa", ShippingPhone = "aaaa", ShippingReciver = "aaa", UserId = "f2de0d50-9fd5-45b3-aa4f-923b843f8b5d", CreateDT = DateTime.UtcNow.AddHours(15), TotalPrice = context.Products.FirstOrDefault().PriceDiscount, OrderStatus = "Đang giao" }, new Order { OrderId = "102", ShippingAddress = "aaa", ShippingPhone = "aaaa", ShippingReciver = "aaa", UserId = "f2de0d50-9fd5-45b3-aa4f-923b843f8b5d", CreateDT = DateTime.UtcNow.AddHours(10), TotalPrice = context.Products.FirstOrDefault().PriceDiscount, OrderStatus = "Đang giao" }, new Order { OrderId = "103", ShippingAddress = "aaa", ShippingPhone = "aaaa", ShippingReciver = "aaa", UserId = "f2de0d50-9fd5-45b3-aa4f-923b843f8b5d", CreateDT = DateTime.UtcNow.AddHours(18), TotalPrice = context.Products.FirstOrDefault().PriceDiscount, OrderStatus = "Đang giao" }, new Order { OrderId = "104", ShippingAddress = "aaa", ShippingPhone = "aaaa", ShippingReciver = "aaa", UserId = "f2de0d50-9fd5-45b3-aa4f-923b843f8b5d", CreateDT = DateTime.UtcNow.AddHours(15), TotalPrice = context.Products.FirstOrDefault().PriceDiscount, OrderStatus = "Đang giao" }, new Order { OrderId = "105", ShippingAddress = "aaa", ShippingPhone = "aaaa", ShippingReciver = "aaa", UserId = "f2de0d50-9fd5-45b3-aa4f-923b843f8b5d", CreateDT = DateTime.UtcNow.AddHours(15), TotalPrice = context.Products.FirstOrDefault().PriceDiscount, OrderStatus = "Đang giao" }, }; await context.Orders.AddRangeAsync(orders); await context.SaveChangesAsync(); } if (!context.OrderItems.Any()) { var orderItems = new List <OrderItem> { new OrderItem { OrderId = 1, ProductId = 1, Quantity = 10 }, new OrderItem { OrderId = 2, ProductId = 1, Quantity = 1 }, new OrderItem { OrderId = 1, ProductId = 2, Quantity = 5 }, }; await context.OrderItems.AddRangeAsync(orderItems); await context.SaveChangesAsync(); } }
public CharacterProgressionsController(GearContext context) { _context = context; }
public GiaRepository(GearContext context) { _context = context; }
public HoaDonRepository(GearContext context) { _context = context; }
public CatalogRepository(GearContext context) { _context = context; }
public OrderItemRepository(GearContext context) { _context = context; }
public ProducerController(GearContext context, IProducerRepository producer) { _context = context; _producer = producer; }
public CatalogController(ICatalogRepository catalog, GearContext context) { _context = context; _catalog = catalog; }