Ejemplo n.º 1
0
        public static async Task SeedOrderStatus(OnovaContext context)
        {
            if (context.OrderStatus.Find(1) == null)
            {
                context.OrderStatus.Add(new OrderStatus
                {
                    Code = "Paid",
                    Name = "Order Paid"
                });
            }

            if (context.OrderStatus.Find(2) == null)
            {
                context.OrderStatus.Add(new OrderStatus
                {
                    Code = "Cancel",
                    Name = "Order Cancel"
                });
            }

            if (context.OrderStatus.Find(3) == null)
            {
                context.OrderStatus.Add(new OrderStatus
                {
                    Code = "Refund",
                    Name = "Order Refund"
                });
            }

            await context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public static async Task SeedStaffs(OnovaContext dbContext)
        {
            if (await dbContext.Staff.CountAsync() == 0)
            {
                var admin = await dbContext.Users.FirstOrDefaultAsync(u => u.UserName == "*****@*****.**");

                var staff = await dbContext.Users.FirstOrDefaultAsync(u => u.UserName == "*****@*****.**");

                var manager = await dbContext.Users.FirstOrDefaultAsync(u => u.UserName == "*****@*****.**");

                var staffInits = new List <Staff>
                {
                    new Staff
                    {
                        StaffId = admin.Id,
                        AddBy   = null,
                        AddDate = DateTime.Now,
                        Address = "Onova",
                        Phone   = "11111111",
                        Salary  = 0
                    },
                    new Staff
                    {
                        StaffId = staff.Id,
                        AddBy   = admin.Id,
                        AddDate = DateTime.Now,
                        Address = "Onova",
                        Phone   = "22222222",
                        Salary  = 0
                    },
                    new Staff
                    {
                        StaffId = manager.Id,
                        AddBy   = admin.Id,
                        AddDate = DateTime.Now,
                        Address = "Onova",
                        Phone   = "22222222",
                        Salary  = 0
                    }
                };

                await dbContext.Staff.AddRangeAsync(staffInits);

                await dbContext.SaveChangesAsync();
            }
        }
Ejemplo n.º 3
0
        public static async Task SeedProductStatus(OnovaContext context)
        {
            if (await context.ProductStatus.FirstOrDefaultAsync(p => p.StatusCode == "Available") == null)
            {
                context.ProductStatus.Add(new ProductStatus
                {
                    StatusCode        = "Available",
                    StatusDescription = "Product Available",
                    StatusName        = "Available"
                });
            }

            if (await context.ProductStatus.FirstOrDefaultAsync(p => p.StatusCode == "SoldOut") == null)
            {
                context.ProductStatus.Add(new ProductStatus
                {
                    StatusCode        = "SoldOut",
                    StatusDescription = "Product Solde Out",
                    StatusName        = "Sold Out"
                });
            }

//            if (await context.ProductStatus.FirstOrDefaultAsync(p => p.StatusCode == "OpenReserve") == null)
//            {
//                context.ProductStatus.Add(new ProductStatus
//                {
//                    StatusCode = "OpenReserve",
//                    StatusDescription = "Product Open for Reserving",
//                    StatusName = "Open Reserve"
//                });
//            }

            if (await context.ProductStatus.FirstOrDefaultAsync(p => p.StatusCode == "StopSelling") == null)
            {
                context.ProductStatus.Add(new ProductStatus
                {
                    StatusCode        = "StopSelling",
                    StatusDescription = "Product Stop Selling",
                    StatusName        = "Stop Selling"
                });
            }

            await context.SaveChangesAsync();
        }