示例#1
0
 private void CreateContactDetail(TrauDatShopDbContext context)
 {
     if (context.ContactDetails.Count() == 0)
     {
         try
         {
             var contactDetail = new TrauDatShop.Model.Models.ContactDetail()
             {
                 Name    = "Trâu Đất Shop",
                 Address = "Số 86B khóm 1 phường 8 TP Cà Mau",
                 Email   = "*****@*****.**",
                 Lat     = 9.1737778,
                 Lng     = 105.142239,
                 Phone   = "01679995384",
                 Website = "http://traudatshop.com",
                 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}\"");
                 }
             }
         }
     }
 }
示例#2
0
 private void CreateSlide(TrauDatShopDbContext 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();
     }
 }
示例#3
0
 private void CreatePage(TrauDatShopDbContext context)
 {
     if (context.Pages.Count() == 0)
     {
         try {
             var page = new Page()
             {
                 Name    = "Giới thiệu",
                 Alias   = "gioi-thieu",
                 Content = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
                         Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                         Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
                         Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 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}\"");
                 }
             }
         }
     }
 }
示例#4
0
 private void CreateFooter(TrauDatShopDbContext 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();
     }
 }