示例#1
0
        private void CreateProductCategory(SmartPhoneDbContext dbContext)
        {
            var user = dbContext.Users.SingleOrDefault(x => x.UserName == "Huy");

            if (dbContext.ProductCategory.Count() == 0)
            {
                var listProductCategory = new List <ProductCategory>()
                {
                    new ProductCategory()
                    {
                        Name        = "Điện Thoại", Alias = "dien-thoai",
                        CreateBy    = user.UserName,
                        CreatedDate = DateTime.Now,
                        Status      = true
                    },
                    new ProductCategory()
                    {
                        Name            = "Iphone", Alias = "iphone", Image = "",
                        MetaDescription = "",
                        CreateBy        = user.UserName,
                        CreatedDate     = DateTime.Now,
                        Status          = true
                    }
                };
                dbContext.ProductCategory.AddRange(listProductCategory);
                dbContext.SaveChanges();
            }
        }
示例#2
0
        private void CreateFooter(SmartPhoneDbContext dbContext)
        {
            var listFooter = new List <Footer>()
            {
                new Footer()
                {
                    Content = "Abc",
                }
            };

            dbContext.Footers.AddRange(listFooter);
            dbContext.SaveChanges();
        }
示例#3
0
        private void CreatePostTag(SmartPhoneDbContext dbContext)
        {
            var listPostTag = new List <PostTag>()
            {
                new PostTag()
                {
                    PostID = 1,
                    TagID  = "samsung"
                }
            };

            dbContext.PostTag.AddRange(listPostTag);
            dbContext.SaveChanges();
        }
示例#4
0
        private void CreateProductTag(SmartPhoneDbContext dbContext)
        {
            var listProductTag = new List <ProductTag>()
            {
                new ProductTag()
                {
                    ProductID = 2,
                    TagID     = "iphone"
                }
            };

            dbContext.ProductTag.AddRange(listProductTag);
            dbContext.SaveChanges();
        }
示例#5
0
        private void CreateMenu(SmartPhoneDbContext dbContext)
        {
            var listMenu = new List <Menu>()
            {
                new Menu()
                {
                    Name   = "Điện Thoại",
                    Target = "_self",
                    Status = true,
                    URL    = "chưa nhập", GroupID = 1
                }
            };

            dbContext.Menu.AddRange(listMenu);
            dbContext.SaveChanges();
        }
示例#6
0
        private void CreateMenuGroup(SmartPhoneDbContext dbContext)
        {
            var listMenuGroup = new List <MenuGroup>()
            {
                new MenuGroup()
                {
                    Name = "menuphai",
                },
                new MenuGroup()
                {
                    Name = "menutrai"
                }
            };

            dbContext.MenuGroups.AddRange(listMenuGroup);
            dbContext.SaveChanges();
        }
示例#7
0
        private void CreatePage(SmartPhoneDbContext dbContext)
        {
            var listPage = new List <Page>()
            {
                new Page()
                {
                    Content         = "",
                    MetaDescription = "",
                    MetaKeyword     = "",
                    Name            = "",
                    Status          = false
                }
            };

            dbContext.Page.AddRange(listPage);
            dbContext.SaveChanges();
        }
示例#8
0
        private void CreateSlide(SmartPhoneDbContext dbContext)
        {
            var listSlide = new List <Slide>()
            {
                new Slide()
                {
                    Image       = "",
                    Description = "giảm giá",
                    Name        = "giảm giá tháng 4",
                    Status      = true,
                    URL         = ""
                }
            };

            dbContext.Slide.AddRange(listSlide);
            dbContext.SaveChanges();
        }
示例#9
0
        private void CreateSuppostOnline(SmartPhoneDbContext dbContext)
        {
            var listSuppostOnline = new List <SuppostOnline>()
            {
                new SuppostOnline()
                {
                    Department = "Hỗ trợ khách hàng",
                    Email      = "*****@*****.**",
                    Name       = "Hoàng Huy",
                    Skype      = "0978962224",
                    Status     = true
                }
            };

            dbContext.SuppostOnline.AddRange(listSuppostOnline);
            dbContext.SaveChanges();
        }
示例#10
0
        private void CreateCustomer(SmartPhoneDbContext dbContext)
        {
            var listCustomer = new List <Customer>()
            {
                new Customer()
                {
                    Account  = "*****@*****.**",
                    Name     = "customer 1",
                    Address  = "gtvt",
                    Password = GetMD5("customer123"),
                    Phone    = 123,
                    Status   = true
                }
            };

            dbContext.Customer.AddRange(listCustomer);
            dbContext.SaveChanges();
        }
示例#11
0
        private void CreateWarranty(SmartPhoneDbContext dbContext)
        {
            var listWarranty = new List <Warranty>()
            {
                new Warranty()
                {
                    Name           = "dCare (mặc định)",
                    WarrantyOld    = "6 tháng",
                    WarrantyNew    = "12 tháng",
                    TimeInnovation = "15 ngày",
                    FixTime        = "21 ngày",
                    Status         = true,
                    Description    = "Các lỗi phần cứng, không bao gồm nguồn, màn hình, vân tay, mất imei, brick, máy có dấu hiệu móp méo, vào nước, hóa chất"
                }
            };

            dbContext.Warranty.AddRange(listWarranty);
            dbContext.SaveChanges();
        }
示例#12
0
        private void CreatePostCategory(SmartPhoneDbContext dbContext)
        {
            var listPostCategory = new List <PostCategory>()
            {
                new PostCategory()
                {
                    Name            = "Tin Điện Thoại",
                    Alias           = "tin-dien-thoai",
                    CreateBy        = "Huy",
                    CreatedDate     = DateTime.Now,
                    MetaDescription = "Tin tức điện thoại mới, nổi bật",
                    Status          = true,
                    MetaKeyword     = "Tin điện thoại",
                }
            };

            dbContext.PostCategory.AddRange(listPostCategory);
            dbContext.SaveChanges();
        }
示例#13
0
        private void CreateTag(SmartPhoneDbContext dbContext)
        {
            var listTag = new List <Tag>()
            {
                new Tag()
                {
                    ID   = "samsung",
                    Name = "samsung",
                    Type = "chưa thêm"
                },
                new Tag()
                {
                    ID   = "iphone",
                    Name = "iphone",
                    Type = "chưa thêm"
                }
            };

            dbContext.Tag.AddRange(listTag);
            dbContext.SaveChanges();
        }
示例#14
0
        private void CreateProduct(SmartPhoneDbContext dbContext)
        {
            var listProduct = new List <Product>()
            {
                new Product()
                {
                    Content     = "chưa",
                    CreateBy    = "Huy",
                    CreatedDate = DateTime.Now,
                    Name        = "Iphone 6s Plus Mới", Alias = convertToUnSign3("Iphone 6s Plus Mới")
                                                                .Replace(" ", "-").ToLower(),
                    Description = "Đẹp như mới, kèm sạc, cable chính hãng",
                    Image       = "chưa", MetaDescription = convertToUnSign3("Đẹp như mới, kèm sạc, cable chính hãng")
                                                            .Replace(" ", "-").ToLower(), MetaKeyword = "iphone-6s-plus", ProductCategoryID = 1,
                    Status         = true,
                    Specifications = "chưa",
                    Quantity       = 20
                }
            };

            dbContext.Product.AddRange(listProduct);
            dbContext.SaveChanges();
        }
示例#15
0
        private void CreatePost(SmartPhoneDbContext dbContext)
        {
            var listPost = new List <Post>()
            {
                new Post()
                {
                    Name  = "Tư vấn: Chọn mua Samsung A30 hay Samsung A50 ?",
                    Alias = convertToUnSign3("Tư vấn: Chọn mua Samsung A30 hay Samsung A50 ?")
                            .Replace(" ", "-").ToLower(),
                    Content         = "chưa",
                    CreateBy        = "Huy",
                    CreatedDate     = DateTime.Now,
                    Description     = "Samsung vừa mang về thị trường Việt Nam 2 sản phẩm tầm trung rất “hot”: Galaxy A30 và Galaxy A50. Vậy Galaxy A30 dành cho những ai, và Galaxy A50 sẽ là sự lựa chọn lý tưởng cho những đối tượng người dùng nào?",
                    Image           = "chưa",
                    MetaDescription = convertToUnSign3("Samsung vừa mang về thị trường Việt Nam 2 sản phẩm tầm trung rất “hot”: Galaxy A30 và Galaxy A50. Vậy Galaxy A30 dành cho những ai, và Galaxy A50 sẽ là sự lựa chọn lý tưởng cho những đối tượng người dùng nào?")
                                      .Replace(" ", "-").ToLower(),
                    MetaKeyword = "mua Samsung A30 hay Samsung A50",
                    Status      = true, PostCategoryID = 1,
                }
            };

            dbContext.Post.AddRange(listPost);
            dbContext.SaveChanges();
        }
示例#16
0
        private void CreateUser(SmartPhoneDbContext dbContext)
        {
            var manager     = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new SmartPhoneDbContext()));
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new SmartPhoneDbContext()));

            var user1 = new ApplicationUser()
            {
                UserName       = "******",
                BirthDay       = DateTime.Parse("01/01/1997"),
                Address        = "DH giao thong van tai",
                PhoneNumber    = "123456",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                FullName       = "Nguyen Le Hoang Huy"
            };
            var user2 = new ApplicationUser()
            {
                UserName       = "******",
                BirthDay       = DateTime.Parse("01/01/1997"),
                Address        = "DH giao thong van tai",
                PhoneNumber    = "123456",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                FullName       = "Ngo Duc Thinh"
            };
            var user3 = new ApplicationUser()
            {
                UserName       = "******",
                BirthDay       = DateTime.Parse("01/01/1997"),
                Address        = "DH giao thong van tai",
                PhoneNumber    = "123456",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                FullName       = "Nguyen Van Teo"
            };

            if (!manager.Users.Any())
            {
                manager.Create(user1, "hoanghuy123");
                manager.Create(user2, "thinh123");
                manager.Create(user3, "teo123");
            }
            if (!roleManager.Roles.Any())
            {
                roleManager.Create(new IdentityRole()
                {
                    Name = "Admin"
                });
                roleManager.Create(new IdentityRole()
                {
                    Name = "Employee"
                });
            }
            var adminUser1 = manager.FindByEmail("*****@*****.**");
            var adminUser2 = manager.FindByEmail("*****@*****.**");
            var adminUser3 = manager.FindByEmail("*****@*****.**");

            manager.AddToRoles(adminUser1.Id, new string[] { "Admin", "Employee" });
            manager.AddToRoles(adminUser2.Id, new string[] { "Admin", "Employee" });
            manager.AddToRoles(adminUser3.Id, new string[] { "Employee" });
        }
示例#17
0
 public ApplicationUserStore(SmartPhoneDbContext context)
     : base(context)
 {
 }
示例#18
0
 public SmartPhoneDbContext Init()
 {
     return(dbContext ?? (dbContext = new SmartPhoneDbContext()));
 }