private void CreateConfigTitle(MobileStoreDbContext context)
 {
     if (!context.SystemConfigs.Any(x => x.Code == "HomeTitle"))
     {
         context.SystemConfigs.Add(new SystemConfig()
         {
             Code        = "HomeTitle",
             ValueString = "Trang chủ MobileStore",
         });
     }
     if (!context.SystemConfigs.Any(x => x.Code == "HomeMetaKeyword"))
     {
         context.SystemConfigs.Add(new SystemConfig()
         {
             Code        = "HomeMetaKeyword",
             ValueString = "Trang chủ MobileStore",
         });
     }
     if (!context.SystemConfigs.Any(x => x.Code == "HomeMetaDescription"))
     {
         context.SystemConfigs.Add(new SystemConfig()
         {
             Code        = "HomeMetaDescription",
             ValueString = "Trang chủ MobileStore",
         });
     }
 }
        private void CreateUser(MobileStoreDbContext context)
        {
            var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new MobileStoreDbContext()));

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

            var user = new ApplicationUser()
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                BirthDay       = DateTime.Now,
                FullName       = "Trần Hữu Toàn"
            };

            if (manager.Users.Count(x => x.UserName == "toan") == 0)
            {
                manager.Create(user, "1234$6789");

                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 CreatePage(MobileStoreDbContext 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 CreateContactDetail(MobileStoreDbContext context)
 {
     if (context.ContactDetails.Count() == 0)
     {
         try
         {
             var contactDetail = new MobileStore.Model.Models.ContactDetail()
             {
                 Name    = "Mobile Store",
                 Address = "Đường 3/2, Phường Xuân Khánh, Quận Ninh Kiều, Thành Phố Cần Thơ",
                 Email   = "*****@*****.**",
                 Lat     = 10.0299337,
                 Lng     = 105.7684266,
                 Phone   = "0987984575",
                 Website = "http://mobilestore.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}\"");
                 }
             }
         }
     }
 }
 private void CreateFooter(MobileStoreDbContext context)
 {
     if (context.Footers.Count(x => x.ID == CommonConstants.DefaultFooterId) == 0)
     {
         string content = "";
     }
 }
 private void CreateFooter(MobileStoreDbContext 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();
     }
 }
        private void CreateSlide(MobileStoreDbContext 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();
            }
        }
Exemple #8
0
 public PhonesController(MobileStoreDbContext context, IHostingEnvironment appEnvironment)
 {
     _context         = context;
     __appEnvironment = appEnvironment;
 }
Exemple #9
0
 public OrderRepository(MobileStoreDbContext mobileStoreDbContext, ShoppingCart shoppingCart)
 {
     _mobileStoreDbContext = mobileStoreDbContext;
     _shoppingCart         = shoppingCart;
 }
 public ApplicationUserStore(MobileStoreDbContext context)
     : base(context)
 {
 }
Exemple #11
0
 public CategoriesController(MobileStoreDbContext context)
 {
     _context = context;
 }
Exemple #12
0
 private ShoppingCart(MobileStoreDbContext mobileStoreDbContext)
 {
     _mobileStoreDbContext = mobileStoreDbContext;
 }
 public CategoryRepository(MobileStoreDbContext mobileStoreDbContext)
 {
     _mobileStoreDbContext = mobileStoreDbContext;
 }
Exemple #14
0
 public PhoneRepository(MobileStoreDbContext mobileStoreDbContext)
 {
     _mobileStoreDbContext = mobileStoreDbContext;
 }
 public OrdersController(MobileStoreDbContext context)
 {
     _context = context;
 }
Exemple #16
0
 public MobileStoreDbContext Init()
 {
     return(dbContext ?? (dbContext = new MobileStoreDbContext()));
 }