public string RegisterUser(RegisterModel model) { try { using (context = new WebStoreDbContext()) { Person user = context.People.Where(x => x.Email == model.Email).FirstOrDefault(); if (user == null) { Person person = new Person() { Email = model.Email, Password = model.Password, // PasswordHash FirstName = model.FirstName, LastName = model.LastName, CreatedAt = DateTime.Now, IsDeleted = false }; context.People.Add(person); context.SaveChanges(); return(""); } } return("Not added"); } catch (Exception e) { throw new Exception(e.Message); } }
private void InitialUserLogin(WebStoreDbContext context) { var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new WebStoreDbContext())); var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new WebStoreDbContext())); var user = new ApplicationUser() { UserName = "******", Email = "*****@*****.**", EmailConfirmed = true, BirthDay = DateTime.Now, FullName = "Nghi Vo" }; manager.Create(user, "@123456@"); 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" }); }
public CatalogController(IProductBusinessLogic productBusinessLogic, IProductImagesBusinessLogic productImagesBusinessLogic, IMapper mapper, WebStoreDbContext context) { _mapper = mapper; _context = context; _productBusinessLogic = productBusinessLogic; _productImagesBusinessLogic = productImagesBusinessLogic; }
public ActionResult GetCollection(int collectionID) { Collection collection = null; using (var cnx = new WebStoreDbContext()) { //collection = cnx.Collections.FirstOrDefault(c => c.CollectionID == collectionID) ViewBag.CollectionID = collectionID; } return(View("collection")); }
private void InitialSlides(WebStoreDbContext context) { if (context.Slides.Count() == 0) { List <Slide> slides = new List <Slide>() { new Slide() { Name = "<span>E</span>-SHOPPER", Description = "Free E-Commerce Template", Image = "/Assets/client/images/home/girl1.jpg", Url = "#", DisplayOrder = 1, Status = true, Content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." }, new Slide() { Name = "<span>E</span>-SHOPPER", Description = "100% Responsive Design", Image = "/Assets/client/images/home/girl2.jpg", Url = "#", DisplayOrder = 2, Status = true, Content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." }, new Slide() { Name = "<span>E</span>-SHOPPER", Description = "Free Ecommerce Template", Image = "/Assets/client/images/home/girl3.jpg", Url = "#", DisplayOrder = 3, Status = true, Content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." } }; context.Slides.AddRange(slides); context.SaveChanges(); } }
private void InitialProductCategory(WebStoreDbContext context) { if (context.ProductCategories.Count() == 0) { List <ProductCategory> list = 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 }, }; context.ProductCategories.AddRange(list); context.SaveChanges(); } }
public static void Initialize(WebStoreDbContext context) { context.Database.EnsureCreated(); if (!context.Product.Any()) { var deps = new Product[] { new Product() { Name = "Product 01" }, new Product() { Name = "Product 02" } }; foreach (var item in deps) { context.Product.Add(item); } context.SaveChanges(); } if (!context.ProductStatus.Any()) { var companies = new ProductStatus[] { new ProductStatus() { Name = "New" } }; foreach (var item in companies) { context.ProductStatus.Add(item); } context.SaveChanges(); } if (!context.ProductAvailabilityStatus.Any()) { var companies = new ProductAvailabilityStatus[] { new ProductAvailabilityStatus() { Name = "Available" }, new ProductAvailabilityStatus() { Name = "Not Available" } }; foreach (var item in companies) { context.ProductAvailabilityStatus.Add(item); } context.SaveChanges(); } if (!context.ProductColor.Any()) { var companies = new ProductColor[] { new ProductColor() { Name = "White" }, new ProductColor() { Name = "Black" } }; foreach (var item in companies) { context.ProductColor.Add(item); } context.SaveChanges(); } if (!context.ProductMetal.Any()) { var companies = new ProductMetal[] { new ProductMetal() { Name = "Gold" }, new ProductMetal() { Name = "Silver" } }; foreach (var item in companies) { context.ProductMetal.Add(item); } context.SaveChanges(); } if (!context.ProductType.Any()) { var types = new ProductType[] { new ProductType() { Name = "Ring" }, new ProductType() { Name = "Earring" } }; foreach (var item in types) { context.ProductType.Add(item); } context.SaveChanges(); } if (!context.Gender.Any()) { var items = new Gender[] { new Gender() { Name = "Чоловіча" }, new Gender() { Name = "Жіноча" } }; foreach (var item in items) { context.Gender.Add(item); } context.SaveChanges(); } }
public ProductapiController(WebStoreDbContext context) { _context = context; }
public UserManager(WebStoreDbContext data, IOptions <TokenModel> tokenManagement) { this.dbContext = data; this._tokenManagement = tokenManagement.Value; }
public CheckoutController(WebStoreDbContext context, IConfiguration configuration) { _context = context; }
public InDbProductData(WebStoreDbContext db) { _db = db; }
public CartController(WebStoreDbContext context) { _context = context; }
public FilterController(WebStoreDbContext context, IProductBusinessLogic productBusinessLogic, IMapper mapper) { _context = context; _productBusinessLogic = productBusinessLogic; _mapper = mapper; }
public ProductMetalRepository(WebStoreDbContext context) { _context = context; }
public GenderRepository(WebStoreDbContext context) { _context = context; }
public ProductRepository(WebStoreDbContext context) { this.context = context; }
public CategoryRepository(WebStoreDbContext context) { this.context = context; }
public LoginController(WebStoreDbContext context) { _context = context; }
public EmployeeRepository(WebStoreDbContext context) { _context = context; }
public BaseManager(WebStoreDbContext db) { this.context = db; }
public UsersRepository(WebStoreDbContext context) : base(context) { }
public WebStoreDbContext Init() { return(dbContext ?? (dbContext = new WebStoreDbContext())); }
public static void Initialize(WebStoreDbContext context) { context.Database.EnsureCreated(); }
public ProductColorRepository(WebStoreDbContext context) { _context = context; }
public ProductRepository(WebStoreDbContext webStoreDbContext) { _context = webStoreDbContext; }
public BaseRepository(WebStoreDbContext context) { this.Context = context ?? throw new ArgumentException("An instance of context is null"); this.DbSet = this.Context.Set <T>(); }
public ProductStatusRepository(WebStoreDbContext context) { _context = context; }
public InDbCartData(WebStoreDbContext db) { _db = db; }
public ProductImageRepository(WebStoreDbContext context) { _context = context; }
public SqlProductData(WebStoreDbContext context) { _context = context; }