Ejemplo n.º 1
0
 private void CreateContactDetail(DITestDbContext context)
 {
     if (context.ContactDetails.Count() == 0)
     {
         try
         {
             var contactDetail = new ContactDetail()
             {
                 Name    = "Shop thời trang TEDU",
                 Address = "Ngõ 77 Xuân La",
                 Email   = "*****@*****.**",
                 Lat     = 21.0633645,
                 Lng     = 105.8053274,
                 Phone   = "095423233",
                 Website = "http://tedu.com.vn",
                 Other   = "",
                 Status  = true
             };
             context.ContactDetails.Add(contactDetail);
             context.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             foreach (var eve in ex.EntityValidationErrors)
             {
                 Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error.");
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\"");
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void CreateConfigTitle(DITestDbContext context)
 {
     if (!context.SystemConfigs.Any(x => x.Code == "HomeTitle"))
     {
         context.SystemConfigs.Add(new SystemConfig()
         {
             Code        = "HomeTitle",
             ValueString = "Trang chủ TeduShop",
         });
     }
     if (!context.SystemConfigs.Any(x => x.Code == "HomeMetaKeyword"))
     {
         context.SystemConfigs.Add(new SystemConfig()
         {
             Code        = "HomeMetaKeyword",
             ValueString = "Trang chủ TeduShop",
         });
     }
     if (!context.SystemConfigs.Any(x => x.Code == "HomeMetaDescription"))
     {
         context.SystemConfigs.Add(new SystemConfig()
         {
             Code        = "HomeMetaDescription",
             ValueString = "Trang chủ TeduShop",
         });
     }
 }
Ejemplo n.º 3
0
 private void CreatePage(DITestDbContext context)
 {
     if (context.Pages.Count() == 0)
     {
         try
         {
             var page = new Page()
             {
                 Name    = "Giới thiệu",
                 Alias   = "gioi-thieu",
                 Content = @"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium ",
                 Status  = true
             };
             context.Pages.Add(page);
             context.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             foreach (var eve in ex.EntityValidationErrors)
             {
                 Trace.WriteLine($"Entity of type \"{eve.Entry.Entity.GetType().Name}\" in state \"{eve.Entry.State}\" has the following validation error.");
                 foreach (var ve in eve.ValidationErrors)
                 {
                     Trace.WriteLine($"- Property: \"{ve.PropertyName}\", Error: \"{ve.ErrorMessage}\"");
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
        //private void CreateUser(DITestDbContext context)
        //{
        //    var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new DITestDbContext()));

        //    var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new DITestDbContext()));

        //    var user = new ApplicationUser()
        //    {
        //        UserName = "******",
        //        Email = "*****@*****.**",
        //        EmailConfirmed = true,
        //        BirthDay = DateTime.Now,
        //        FullName = "Technology Education"

        //    };
        //    if (manager.Users.Count(x => x.UserName == "tedu") == 0)
        //    {
        //        manager.Create(user, "123654$");

        //        if (!roleManager.Roles.Any())
        //        {
        //            roleManager.Create(new IdentityRole { Name = "Admin" });
        //            roleManager.Create(new IdentityRole { Name = "User" });
        //        }

        //        var adminUser = manager.FindByEmail("*****@*****.**");

        //        manager.AddToRoles(adminUser.Id, new string[] { "Admin", "User" });
        //    }

        //}
        private void CreateProductCategorySample(DITestDbContext context)
        {
            if (context.ProductCategories.Count() == 0)
            {
                List <ProductCategory> listProductCategory = new List <ProductCategory>()
                {
                    new ProductCategory()
                    {
                        Name = "Điện lạnh", Alias = "dien-lanh", Status = true
                    },
                    new ProductCategory()
                    {
                        Name = "Viễn thông", Alias = "vien-thong", Status = true
                    },
                    new ProductCategory()
                    {
                        Name = "Đồ gia dụng", Alias = "do-gia-dung", Status = true
                    },
                    new ProductCategory()
                    {
                        Name = "Mỹ phẩm", Alias = "my-pham", Status = true
                    }
                };
                context.ProductCategories.AddRange(listProductCategory);
                context.SaveChanges();
            }
        }
Ejemplo n.º 5
0
 private void CreateFooter(DITestDbContext context)
 {
     if (context.Footers.Count(x => x.ID == CommonConstants.DefaultFooterId) == 0)
     {
         string content = "Footer";
         context.Footers.Add(new Footer()
         {
             ID      = CommonConstants.DefaultFooterId,
             Content = content
         });
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
        private void CreateSlide(DITestDbContext context)
        {
            if (context.Slides.Count() == 0)
            {
                List <Slide> listSlide = new List <Slide>()
                {
                    new Slide()
                    {
                        Name         = "Slide 1",
                        DisplayOrder = 1,
                        Status       = true,
                        Url          = "#",
                        Image        = "/Assets/client/images/bag.jpg",
                        Content      = @"	<h2>FLAT 50% 0FF</h2>
                                <label>FOR ALL PURCHASE <b>VALUE</b></label>
                                <p>Lorem ipsum dolor sit amet, consectetur 
                            adipisicing elit, sed do eiusmod tempor incididunt ut labore et </ p >
                        <span class=""on-get"">GET NOW</span>"
                    },
                    new Slide()
                    {
                        Name         = "Slide 2",
                        DisplayOrder = 2,
                        Status       = true,
                        Url          = "#",
                        Image        = "/Assets/client/images/bag1.jpg",
                        Content      = @"<h2>FLAT 50% 0FF</h2>
                                <label>FOR ALL PURCHASE <b>VALUE</b></label>

                                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et </ p >

                                <span class=""on-get"">GET NOW</span>"
                    },
                };
                context.Slides.AddRange(listSlide);
                context.SaveChanges();
            }
        }
Ejemplo n.º 7
0
 public DITestDbContext Init()
 {
     return(dbContext ?? (dbContext = new DITestDbContext()));
 }