예제 #1
0
        private async Task <StockReceiving> MakeNewStockReceiving(StockReceiving stockReceiving)
        {
            var newStockReceiving = await _context.StockReceiving
                                    .Where(m => m.StockReceivingID == stockReceiving.StockReceivingID).Include(m => m.Supplier).SingleOrDefaultAsync();

            newStockReceiving.SupplierID = stockReceiving.SupplierID;
            return(newStockReceiving);
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("StockReceivingID,Date,SupplierID,ApplicationUserID")] StockReceiving stockReceiving)
        {
            if (ModelState.IsValid)
            {
                stockReceiving.ApplicationUserID = _userManager.GetUserId(User);
                stockReceiving.Date             = DateTime.Now;
                stockReceiving.StockReceivingID = Guid.NewGuid();
                _context.Add(stockReceiving);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = stockReceiving.StockReceivingID }));
            }
            ViewData["SupplierID"] = new SelectList(_context.Supplier, "SupplierID", "Name", stockReceiving.SupplierID);
            return(View(stockReceiving));
        }
예제 #3
0
        public async Task <IActionResult> Edit(Guid id, StockReceiving stockReceiving)
        {
            if (id != stockReceiving.StockReceivingID)
            {
                return(NotFound());
            }



            if (ModelState.IsValid)
            {
                try
                {
                    var item     = MakeNewStockReceiving(stockReceiving).Result;
                    var timeSpan = DateTime.Now - item.Date;
                    if (timeSpan.TotalHours > 2)
                    {
                        ViewData["ErrorText"] = "Không thể sửa đơn nhập hàng sau 2 giờ";
                        return(View("ErrorPage"));
                    }
                    var isAuthorized = await _authorizationService.AuthorizeAsync(User, item,
                                                                                  OrderOperations.Update);

                    if (!isAuthorized.Succeeded)
                    {
                        return(new ChallengeResult());
                    }
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StockReceivingExists(stockReceiving.StockReceivingID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(RedirectToAction(nameof(Details), new { id = stockReceiving.StockReceivingID }));
        }
예제 #4
0
        public static async Task Initialize(IServiceProvider serviceProvider, string testUserPw)
        {
            using (var context = new ApplicationDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <ApplicationDbContext> >()))
            {
                // For sample purposes we are seeding 2 users both with the same password.
                // The password is set with the following command:
                // dotnet user-secrets set SeedUserPW <pw>
                // The admin user can do anything

                // Check that database has had anything
                // Look for any movies.
                if (context.ApplicationUser.Any())
                {
                    return;   // DB has been seeded
                }

                //var listApplicationUserID = await InitApplicationUser(serviceProvider, testUserPw);

                //var adminID = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                //await EnsureRole(serviceProvider, adminID, Constants.AdminRole);

                var admin = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Admin",
                    LastName    = "Nguyen",
                    Birthday    = DateTime.Parse("1991-09-20"),
                    Phone       = "0838442463",
                    PhoneNumber = "0838442463",
                    Address     = "42/10 Mai Văn Ngọc, Gò Vấp",
                    Role        = UserRole.Admin
                };
                admin = await CreateApplicationUser(serviceProvider, admin, testUserPw);

                var adminID = admin.Id;
                await EnsureRole(serviceProvider, adminID, Constants.AdminRole);

                // allowed user can create and edit contacts that they create
                //var saleID = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                //await EnsureRole(serviceProvider, saleID, Constants.SaleRole);

                var sale = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Sale",
                    LastName    = "Nguyen",
                    Birthday    = DateTime.Parse("1991-09-20"),
                    Phone       = "0838442463",
                    PhoneNumber = "0838442463",
                    Address     = "42/10 Mai Văn Ngọc, Gò Vấp",
                    Role        = UserRole.Sale
                };
                sale = await CreateApplicationUser(serviceProvider, sale, testUserPw);

                var saleID = sale.Id;
                await EnsureRole(serviceProvider, saleID, Constants.SaleRole);

                //var warehousemanagerID = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                //await EnsureRole(serviceProvider, warehousemanagerID, Constants.WarehouseManagerRole);

                var warehouseManager = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Warehouse Manager",
                    LastName    = "Nguyen",
                    Birthday    = DateTime.Parse("1991-09-20"),
                    Phone       = "0838442463",
                    PhoneNumber = "0838442463",
                    Address     = "42/10 Mai Văn Ngọc, Gò Vấp",
                    Role        = UserRole.WarehouseManager
                };
                warehouseManager = await CreateApplicationUser(serviceProvider, warehouseManager, testUserPw);

                var warehouseManagerID = warehouseManager.Id;
                await EnsureRole(serviceProvider, warehouseManagerID, Constants.WarehouseManagerRole);

                //var technicalID = await EnsureUser(serviceProvider, testUserPw, "*****@*****.**");
                //await EnsureRole(serviceProvider, technicalID, Constants.TechnicalRole);

                var technical = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Technical",
                    LastName    = "Nguyen",
                    Birthday    = DateTime.Parse("1991-09-20"),
                    Phone       = "0838442463",
                    PhoneNumber = "0838442463",
                    Address     = "42/10 Mai Văn Ngọc, Gò Vấp",
                    Role        = UserRole.Technical
                };
                technical = await CreateApplicationUser(serviceProvider, technical, testUserPw);

                var technicalID = technical.Id;
                await EnsureRole(serviceProvider, technicalID, Constants.TechnicalRole);

                //var adminTwoID = await EnsureUser(serviceProvider, "Abc123456!", "*****@*****.**");
                //await EnsureRole(serviceProvider, adminTwoID, Constants.AdminRole);

                var adminTwo = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Admin Two",
                    LastName    = "Nguyen",
                    Birthday    = DateTime.Parse("1991-09-20"),
                    Phone       = "0838442463",
                    PhoneNumber = "0838442463",
                    Address     = "42/10 Mai Văn Ngọc, Gò Vấp",
                    Role        = UserRole.Admin
                };
                adminTwo = await CreateApplicationUser(serviceProvider, adminTwo, "Abc123456!");

                var adminTwoID = adminTwo.Id;
                await EnsureRole(serviceProvider, adminTwoID, Constants.AdminRole);

                // Add Full info Admin user
                var employerToanAdmin = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Toan",
                    LastName    = "Nguyen Thanh Thien",
                    Birthday    = DateTime.Parse("1992-09-20"),
                    Phone       = "01672699288",
                    PhoneNumber = "01672699288",
                    Address     = "30/15 Đặng Văn Bi, Gò Vấp",
                    Role        = UserRole.Admin
                };
                employerToanAdmin = await CreateApplicationUser(serviceProvider, employerToanAdmin, "Abc123456!");
                await EnsureRole(serviceProvider, employerToanAdmin.Id, Constants.AdminRole);

                // Add Full info Sale user
                var employerThuSale = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Thư",
                    LastName    = "Châu Hồng Anh",
                    Birthday    = DateTime.Parse("1996-03-16"),
                    Phone       = "0168794582",
                    PhoneNumber = "0168794582",
                    Address     = "80 Cách Mạng Tháng 8, Tân Bình",
                    Role        = UserRole.Sale
                };
                employerThuSale = await CreateApplicationUser(serviceProvider, employerThuSale, "Abc123456!");
                await EnsureRole(serviceProvider, employerThuSale.Id, Constants.SaleRole);

                // Add Full info WarehouseManager user
                var employerSinhWarehouse = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Sinh",
                    LastName    = "Nguyễn Tri",
                    Birthday    = DateTime.Parse("1996-08-10"),
                    Phone       = "01672699288",
                    PhoneNumber = "01672699288",
                    Address     = "162 Huỳnh Văn Bánh, Quận Phú Nhuận",
                    Role        = UserRole.WarehouseManager
                };
                employerSinhWarehouse = await CreateApplicationUser(serviceProvider, employerSinhWarehouse, "Abc123456!");
                await EnsureRole(serviceProvider, employerSinhWarehouse.Id, Constants.WarehouseManagerRole);

                // Add Full info Technical user
                var employerNgaTechnical = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Nga",
                    LastName    = "Võ Thị Thúy",
                    Birthday    = DateTime.Parse("1996-10-05"),
                    Phone       = "0983254435",
                    PhoneNumber = "0983254435",
                    Address     = "ktx khu B Dĩ An, tỉnh Bình Dương",
                    Role        = UserRole.Technical
                };
                employerNgaTechnical = await CreateApplicationUser(serviceProvider, employerNgaTechnical, "Abc123456!");
                await EnsureRole(serviceProvider, employerNgaTechnical.Id, Constants.TechnicalRole);

                // Add Full info Accountant user
                var employerPhuongAccountant = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    FirstName   = "Phương",
                    LastName    = "Nguyễn Lan",
                    Birthday    = DateTime.Parse("1996-07-13"),
                    Phone       = "0983254435",
                    PhoneNumber = "0983254435",
                    Address     = "ktx khu B Dĩ An, tỉnh Bình Dương",
                    Role        = UserRole.Accountant
                };
                employerNgaTechnical = await CreateApplicationUser(serviceProvider, employerPhuongAccountant, "Abc123456!");
                await EnsureRole(serviceProvider, employerPhuongAccountant.Id, Constants.AccountantRole);

                #region Snipset_Seeddata

                var constants = new Constant[]
                {
                    new Constant {
                        Name = "Hạn đổi trả", Description = "Thời hạn mà người dùng có thể đổi trả sản phẩm tính từ lúc lập phiếu bảo hành", Parameter = 7
                    }
                };

                foreach (Constant constant in constants)
                {
                    context.Add(constant);
                }

                context.SaveChanges();

                #region Customer
                var customers = new Customer[]
                {
                    new Customer {
                        Name    = "Trần Thị Thanh Thảo", Phone = "01672699288", Address = "164 Huỳnh Văn Bánh, quận Phú Nhuận", Birthday = DateTime.Parse("1996-07-13"), Gender = GenderType.Female,
                        Country = "Vietnam"
                    },
                    new Customer {
                        Name    = "Trần Đức Duy", Phone = "0983254435", Address = "335/13 Nguyễn Thái Sơn, quận Gò Vấp", Birthday = DateTime.Parse("1992-04-01"), Gender = GenderType.Male,
                        Country = "Vietnam"
                    },
                    new Customer {
                        Name    = "Phạm Đình Vy", Phone = "0167254435", Address = "335/13 Nguyễn Thái Sơn, quận Gò Vấp", Birthday = DateTime.Parse("1991-04-01"), Gender = GenderType.Male,
                        Country = "Vietnam"
                    }
                };

                foreach (Customer c in customers)
                {
                    context.Customer.Add(c);
                }

                context.SaveChanges();
                #endregion

                #region Brand
                var brands = new Brand[]
                {
                    new Brand {
                        Name = "Samsung", Country = "Hàn Quốc", Description = "Không có"
                    },
                    new Brand {
                        Name = "Apple", Country = "USA", Description = ""
                    },
                    new Brand {
                        Name = "Oppo", Country = "China", Description = ""
                    },
                    new Brand {
                        Name = "JBL", Country = "USA", Description = ""
                    },
                    new Brand {
                        Name = "ESaver", Country = "Vietnam", Description = ""
                    }
                };

                foreach (Brand brand in brands)
                {
                    context.Brand.Add(brand);
                }

                context.SaveChanges();
                #endregion

                #region Supplier
                var suppliers = new Supplier[]
                {
                    new Supplier {
                        Name    = "FPT", Address = "Lô 37-39A, đường 19, KCX Tân Thuận, Tân Thuận Đông, Q7", Phone = "+84 7300 2222", Email = "*****@*****.**", Code = "500000", Status = SupplierStatus.Active,
                        PicName = "Nguyễn Văn A", PicEmail = "*****@*****.**", PicPhone = "+84 7300 2222"
                    },
                    new Supplier {
                        Name    = "Viettel", Address = "174 Trần Quang Khải, quận 1", Phone = "0963100900", Email = "*****@*****.**", Code = "500000", Status = SupplierStatus.Active,
                        PicName = "Viettel", PicEmail = "*****@*****.**", PicPhone = "0963100900"
                    },
                    new Supplier {
                        Name    = "The Gioi Di Dong", Address = "128 Trần Quang Khải, P. Tân Định, Q.1", Phone = "18001060", Email = "*****@*****.**", Code = "500000", Status = SupplierStatus.Active,
                        PicName = "The Gioi Di Dong", PicEmail = "*****@*****.**", PicPhone = "18001060"
                    }
                };

                foreach (Supplier s in suppliers)
                {
                    context.Supplier.Add(s);
                }

                context.SaveChanges();
                #endregion

                #region Model
                var models = new Model[]
                {
                    new Model {
                        Name    = "Samsung Galaxy j7 Pro 64gbs", Color = "Black", Description = "Là chiếc điện thoại cao cấp thời thượng của giới trẻ", Specification = "Chip 8 nhân, Ram 3Gbs, ROM 64Gbs", Type = ModelType.Device,
                        BrandID = brands.Single(i => i.Name == "Samsung").BrandID
                    },
                    new Model {
                        Name    = "Samsung Galaxy A8+ (2018)", Color = "Grey", Description = "Là chiếc điện thoại cao cấp thời thượng của giới trẻ", Specification = "Chip 8 nhân, Ram 4Gbs, ROM 64Gbs", Type = ModelType.Device,
                        BrandID = brands.Single(i => i.Name == "Samsung").BrandID
                    },
                    new Model {
                        Name    = "IPhone X 64Gbs", Color = "Black", Description = "Smart phone cao cấp", Specification = "Chip 8 nhân, Ram 4Gbs, ROM 64Gbs", Type = ModelType.Device,
                        BrandID = brands.Single(i => i.Name == "Apple").BrandID
                    },
                    new Model {
                        Name    = "IPhone 8 128Gbs", Color = "Black", Description = "Smart phone cao cấp", Specification = "Chip 8 nhân, Ram 4Gbs, ROM 64Gbs", Type = ModelType.Device,
                        BrandID = brands.Single(i => i.Name == "Apple").BrandID
                    },
                    new Model {
                        Name    = "Tai Nghe JBL T450BT", Color = "Black", Description = "Tai nghe cao cấp", Specification = "", Type = ModelType.Accessory,
                        BrandID = brands.Single(i => i.Name == "JBL").BrandID
                    },
                    new Model {
                        Name    = "Dây cáp Micro USB 0.2 m eSaver BST-0728", Color = "White", Description = "Dây cáp sạc", Specification = "", Type = ModelType.Accessory,
                        BrandID = brands.Single(i => i.Name == "ESaver").BrandID
                    }
                };

                foreach (Model m in models)
                {
                    context.Model.Add(m);
                }

                context.SaveChanges();
                #endregion

                #region StockReceiving
                var stockReceivings = new StockReceiving[]
                {
                    new StockReceiving {
                        Date = DateTime.Parse("2017-08-21 7:34:42Z"), SupplierID = suppliers.Single(i => i.Name == "FPT").SupplierID, ApplicationUserID = employerSinhWarehouse.Id
                    },
                    new StockReceiving {
                        Date = DateTime.Parse("2017-10-15 11:34:42Z"), SupplierID = suppliers.Single(i => i.Name == "The Gioi Di Dong").SupplierID, ApplicationUserID = employerSinhWarehouse.Id
                    },
                    new StockReceiving {
                        Date = DateTime.Parse("2017-12-15 11:34:42Z"), SupplierID = suppliers.Single(i => i.Name == "Viettel").SupplierID, ApplicationUserID = employerSinhWarehouse.Id
                    },
                };

                foreach (StockReceiving sr in stockReceivings)
                {
                    context.StockReceiving.Add(sr);
                }

                context.SaveChanges();
                #endregion

                #region ModelFromSupplier
                var modelFromSuppliers = new ModelFromSupplier[]
                {
                    new ModelFromSupplier {
                        Quantity         = 2, PriceBought = 22000000, PriceSold = 34000000, Date = DateTime.Parse("2017-08-21 7:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "IPhone X 64Gbs").ModelID,
                        StockReceivingID = stockReceivings[0].StockReceivingID
                    },
                    new ModelFromSupplier {
                        Quantity         = 1, PriceBought = 15000000, PriceSold = 24000000, Date = DateTime.Parse("2017-08-21 7:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "Samsung Galaxy A8+ (2018)").ModelID,
                        StockReceivingID = stockReceivings[0].StockReceivingID
                    },
                    new ModelFromSupplier {
                        Quantity         = 3, PriceBought = 800000, PriceSold = 1200000, Date = DateTime.Parse("2017-08-21 7:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "Tai Nghe JBL T450BT").ModelID,
                        StockReceivingID = stockReceivings[0].StockReceivingID
                    },
                    new ModelFromSupplier {
                        Quantity         = 2, PriceBought = 800000, PriceSold = 1200000, Date = DateTime.Parse("2017-10-15 11:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "Tai Nghe JBL T450BT").ModelID,
                        StockReceivingID = stockReceivings[1].StockReceivingID
                    },
                    new ModelFromSupplier {
                        Quantity         = 2, PriceBought = 80000, PriceSold = 150000, Date = DateTime.Parse("2017-10-15 11:34:42Z"), Period = 3, ModelID = models.Single(i => i.Name == "Dây cáp Micro USB 0.2 m eSaver BST-0728").ModelID,
                        StockReceivingID = stockReceivings[1].StockReceivingID
                    },
                    new ModelFromSupplier {
                        Quantity         = 3, PriceBought = 22000000, PriceSold = 32000000, Date = DateTime.Parse("2017-08-21 7:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "IPhone X 64Gbs").ModelID,
                        StockReceivingID = stockReceivings[0].StockReceivingID
                    },

                    //Stock Receiving [2] (06-01-2017)
                    new ModelFromSupplier {
                        Quantity         = 4, PriceBought = 14000000, PriceSold = 23000000, Date = DateTime.Parse("2017-12-15 11:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "Samsung Galaxy A8+ (2018)").ModelID,
                        StockReceivingID = stockReceivings[2].StockReceivingID
                    },
                    new ModelFromSupplier {
                        Quantity         = 2, PriceBought = 18000000, PriceSold = 26000000, Date = DateTime.Parse("2017-12-15 11:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "IPhone 8 128Gbs").ModelID,
                        StockReceivingID = stockReceivings[2].StockReceivingID
                    },

                    //Stock Receiving [0] (06-01-2017)
                    new ModelFromSupplier {
                        Quantity         = 2, PriceBought = 80000, PriceSold = 150000, Date = DateTime.Parse("2017-08-21 7:34:42Z"), Period = 3, ModelID = models.Single(i => i.Name == "Dây cáp Micro USB 0.2 m eSaver BST-0728").ModelID,
                        StockReceivingID = stockReceivings[0].StockReceivingID
                    },
                    new ModelFromSupplier {
                        Quantity         = 3, PriceBought = 12000000, PriceSold = 18000000, Date = DateTime.Parse("2017-08-21 7:34:42Z"), Period = 12, ModelID = models.Single(i => i.Name == "Samsung Galaxy j7 Pro 64gbs").ModelID,
                        StockReceivingID = stockReceivings[0].StockReceivingID
                    },
                };

                foreach (ModelFromSupplier mfs in modelFromSuppliers)
                {
                    context.ModelFromSupplier.Add(mfs);
                }

                context.SaveChanges();
                #endregion

                #region Item
                var items = new Item[]
                {
                    new Item {
                        IMEI    = "2546CQC189CQ438CSA", SerializerNumber = "220167955897642", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[0].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "IPhone X 64Gbs").ModelID
                    },
                    new Item {
                        IMEI    = "QC587QC189C8468CSA", SerializerNumber = "387457952854642", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[0].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "IPhone X 64Gbs").ModelID
                    },
                    new Item {
                        IMEI    = "59189VEB69C8468CSA", SerializerNumber = "387457952854642", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[1].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy A8+ (2018)").ModelID
                    },
                    // Model From Supplier [2] - 3
                    new Item {
                        IMEI    = "8642134FW528468CSA", SerializerNumber = "487995313284612", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[2].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Tai Nghe JBL T450BT").ModelID
                    },
                    new Item {
                        IMEI    = "CE468CQF2FW87VWSCE", SerializerNumber = "652217985431287", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[2].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Tai Nghe JBL T450BT").ModelID
                    },
                    new Item {
                        IMEI    = "PIV477VWV658VWC249", SerializerNumber = "320549785423187", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[2].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Tai Nghe JBL T450BT").ModelID
                    },
                    // Model From Supplier [3] - 2
                    new Item {
                        IMEI    = "5846AVRW69C8468CSA", SerializerNumber = "587643215854642", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[3].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Tai Nghe JBL T450BT").ModelID
                    },
                    new Item {
                        IMEI    = "589CQVLC5495V68CSA", SerializerNumber = "302164897524642", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[3].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Tai Nghe JBL T450BT").ModelID
                    },
                    // Model From Supplier [4] - 2
                    new Item {
                        IMEI    = "TY7985CQC46CQE879V", SerializerNumber = "978521347852794", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[4].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Dây cáp Micro USB 0.2 m eSaver BST-0728").ModelID
                    },
                    new Item {
                        IMEI    = "CV7854VWV6216VWV58", SerializerNumber = "217985462318746", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[4].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Dây cáp Micro USB 0.2 m eSaver BST-0728").ModelID
                    },

                    // Model From Supplier [5] - 3 (06-01-2017)
                    new Item {
                        IMEI    = "VW864CWC8643VWV842", SerializerNumber = "546789531582314", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[5].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "IPhone X 64Gbs").ModelID
                    },
                    new Item {
                        IMEI    = "38VW4862VWV879VEV8", SerializerNumber = "698462135974568", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[5].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "IPhone X 64Gbs").ModelID
                    },
                    new Item {
                        IMEI    = "3186WVV86VEPM567VW", SerializerNumber = "135679885465431", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[5].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "IPhone X 64Gbs").ModelID
                    },

                    // Model From Supplier [6] - 4 (06-01-2017)
                    new Item {
                        IMEI    = "2587CQC6452VQV8466", SerializerNumber = "521346899522846", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[6].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy A8+ (2018)").ModelID
                    },
                    new Item {
                        IMEI    = "VWV7546VW89CWV54FW", SerializerNumber = "465231346558654", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[6].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy A8+ (2018)").ModelID
                    },
                    new Item {
                        IMEI    = "VWHWH84648GW5LHA54", SerializerNumber = "231665846589756", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[6].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy A8+ (2018)").ModelID
                    },
                    new Item {
                        IMEI    = "CGWG89754FQGE85FQW", SerializerNumber = "234658946532135", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[6].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy A8+ (2018)").ModelID
                    },

                    // Model From Supplier [7] - 2 (06-01-2017)
                    new Item {
                        IMEI    = "EE5648CWV64658VWEV", SerializerNumber = "523134688945621", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[7].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "IPhone 8 128Gbs").ModelID
                    },
                    new Item {
                        IMEI    = "VWV65489WVV54VV632", SerializerNumber = "132564789552358", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[7].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "IPhone 8 128Gbs").ModelID
                    },

                    // Model From Supplier [8] - 2 (06-01-2017)
                    new Item {
                        IMEI    = "VDW846VWV87VWV6542", SerializerNumber = "135979855231465", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[8].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Dây cáp Micro USB 0.2 m eSaver BST-0728").ModelID
                    },
                    new Item {
                        IMEI    = "CWV879VW8VW54VSV87", SerializerNumber = "165879551325879", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[8].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Dây cáp Micro USB 0.2 m eSaver BST-0728").ModelID
                    },

                    //Model From Supplier [9] - 3 (06-01-2017)
                    new Item {
                        IMEI    = "PQJ4658CWV642318CW", SerializerNumber = "313587954621356", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[9].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy j7 Pro 64gbs").ModelID
                    },
                    new Item {
                        IMEI    = "POQ5468VWE612VVW87", SerializerNumber = "853132579856423", Note = "", Status = ItemStatus.Sold, ModelFromSupplierID = modelFromSuppliers[9].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy j7 Pro 64gbs").ModelID
                    },
                    new Item {
                        IMEI    = "VWV798VWV56VS213VW", SerializerNumber = "985645675213258", Note = "", Status = ItemStatus.InStock, ModelFromSupplierID = modelFromSuppliers[9].ModelFromSupplierID,
                        ModelID = models.Single(i => i.Name == "Samsung Galaxy j7 Pro 64gbs").ModelID
                    },
                };

                foreach (Item i in items)
                {
                    context.Item.Add(i);
                }

                context.SaveChanges();
                #endregion

                #region Order
                var orders = new Order[]
                {
                    new Order {
                        Total = 34000000, Date = DateTime.Parse("2017-08-29 7:34:42Z"), IsPrinted = true, CustomerID = customers[0].CustomerID, ApplicationUserID = employerThuSale.Id
                    },
                    new Order {
                        Total = 25200000, Date = DateTime.Parse("2017-09-05 11:34:42Z"), IsPrinted = true, CustomerID = customers[1].CustomerID, ApplicationUserID = saleID
                    },
                    new Order {
                        Total = 1350000, Date = DateTime.Parse("2017-09-16 15:24:42Z"), IsPrinted = true, CustomerID = customers[2].CustomerID, ApplicationUserID = employerThuSale.Id
                    },
                    new Order {
                        Total = 18000000, Date = DateTime.Parse("2017-10-21 8:24:42Z"), IsPrinted = true, CustomerID = customers[1].CustomerID, ApplicationUserID = employerThuSale.Id
                    },
                    new Order {
                        Total = 19200000, Date = DateTime.Parse("2017-11-21 8:24:42Z"), IsPrinted = true, CustomerID = customers[0].CustomerID, ApplicationUserID = saleID
                    },
                    new Order {
                        Total = 26000000, Date = DateTime.Parse("2017-12-03 8:24:42Z"), IsPrinted = true, CustomerID = customers[2].CustomerID, ApplicationUserID = employerThuSale.Id
                    },
                    new Order {
                        Total = 34000000, Date = DateTime.Parse("2017-11-23 8:24:42Z"), IsPrinted = true, CustomerID = customers[0].CustomerID, ApplicationUserID = saleID
                    },
                };

                foreach (Order order in orders)
                {
                    context.Order.Add(order);
                }

                context.SaveChanges();
                #endregion

                #region OrderDetail
                var orderDetails = new OrderDetail[]
                {
                    new OrderDetail {
                        PriceSold = 34000000, ItemID = items[0].ItemID, OrderID = orders[0].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 24000000, ItemID = items[2].ItemID, OrderID = orders[1].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 1200000, ItemID = items[3].ItemID, OrderID = orders[1].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 1200000, ItemID = items[4].ItemID, OrderID = orders[2].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 150000, ItemID = items[8].ItemID, OrderID = orders[2].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 18000000, ItemID = items[21].ItemID, OrderID = orders[3].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 18000000, ItemID = items[22].ItemID, OrderID = orders[4].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 1200000, ItemID = items[5].ItemID, OrderID = orders[4].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 26000000, ItemID = items[17].ItemID, OrderID = orders[5].OrderID
                    },
                    new OrderDetail {
                        PriceSold = 34000000, ItemID = items[1].ItemID, OrderID = orders[6].OrderID
                    },
                };

                foreach (OrderDetail orderDetail in orderDetails)
                {
                    context.OrderDetail.Add(orderDetail);
                }

                context.SaveChanges();
                #endregion

                #region WarrantyCard
                var warrantyCards = new WarrantyCard[]
                {
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-08-29"), EndDate = DateTime.Parse("2018-08-29"), ItemID = items[0].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = employerThuSale.Id
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-09-05"), EndDate = DateTime.Parse("2018-09-05"), ItemID = items[2].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = employerThuSale.Id
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-09-05"), EndDate = DateTime.Parse("2018-09-05"), ItemID = items[3].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = employerThuSale.Id
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-09-16"), EndDate = DateTime.Parse("2018-09-16"), ItemID = items[4].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = employerThuSale.Id
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-09-16"), EndDate = DateTime.Parse("2017-12-16"), ItemID = items[8].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = employerThuSale.Id
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-10-21"), EndDate = DateTime.Parse("2018-10-21"), ItemID = items[21].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = employerThuSale.Id
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-11-21"), EndDate = DateTime.Parse("2018-11-21"), ItemID = items[22].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = saleID
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-11-21"), EndDate = DateTime.Parse("2018-11-21"), ItemID = items[5].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = saleID
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-12-03"), EndDate = DateTime.Parse("2018-12-03"), ItemID = items[17].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = employerThuSale.Id
                    },
                    new WarrantyCard {
                        NumberOfWarranty = 0, StartDate = DateTime.Parse("2017-11-23"), EndDate = DateTime.Parse("2018-11-23"), ItemID = items[1].ItemID, IsPrinted = true, IsDisabled = false,
                        TransactionCode  = Guid.NewGuid(), ApplicationUserID = saleID
                    },
                };

                foreach (WarrantyCard warrantyCard in warrantyCards)
                {
                    context.WarrantyCard.Add(warrantyCard);
                }

                context.SaveChanges();
                #endregion

                #endregion
            }
        }