private void CreateProductCategorySample(TheTechShopDbContext 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(); } }
private void CreateUser(TheTechShopDbContext context) { //var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new TheTechShopDbContext())); //var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new TheTechShopDbContext())); //var user = new ApplicationUser() //{ // UserName = "******", // Email = "*****@*****.**", // EmailConfirmed = true, // BirthDay = DateTime.Now, // FullName = "Tran nam hai" //}; //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 CreateContactDetail(TheTechShopDbContext context) { if (context.ContactDetails.Count() == 0) { try { var contactDetail = new ContactDetail() { Name = "Shop", Address = "Bình Thạnh", Email = "*****@*****.**", Lat = 10.8045657, Lng = 106.6945956, Phone = "0963177497", Website = "http://thetech.com.vn", Order = "", 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}\""); } } } } }
private void CreatePage(TheTechShopDbContext 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}\""); } } } } }
private void CreateFooter(TheTechShopDbContext context) { if (context.Footers.Count(x => x.ID == CommonConstants.DefaultFooterId) == 0) { var footer = new Footer() { ID = "default", Content = "TheTechShop" }; context.Footers.Add(footer); context.SaveChanges(); } }
private void CreateSlide(TheTechShopDbContext 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(); } }
public TheTechShopDbContext Init() { return(dbContext ?? (dbContext = new TheTechShopDbContext())); }
public ApplicationUserStore(TheTechShopDbContext context) : base(context) { }