public bool login(User model) { using (var context = new OnlineShopingEntities()) { bool isValid = context.Users.Any(x => x.UserName == model.UserName && x.Password == model.Password); return(isValid); } }
// GET: UpdateProduct //Update Price Info public ActionResult UpdatePriceInfo() { ProductPriceUpdateModel productPriceUpdateModel = new ProductPriceUpdateModel(); using (var context = new OnlineShopingEntities()) { productPriceUpdateModel.products = context.Products.ToList(); } return(View(productPriceUpdateModel)); }
public ActionResult InsertProductInfo() { ProductModel productModel = new ProductModel(); using (var context = new OnlineShopingEntities()) { productModel.categories = context.Categories.ToList(); } return(View(productModel)); }
public int InsertCategory(Category model) { using (var context = new OnlineShopingEntities()) { Category category = new Category() { CategoryName = model.CategoryName }; context.Categories.Add(category); context.SaveChanges(); return(category.CategoryId); } }
public int Operation(RegistrationModel model) { using (var context = new OnlineShopingEntities()) { User user = new User() { UserName = model.UserName, Password = HashFunction(model.Password) }; context.Users.Add(user); context.SaveChanges(); return(user.UserId); } }
public int InsertProduct(ProductModel model) { using (var context = new OnlineShopingEntities()) { Product product = new Product() { ProductName = model.ProductName, Price = model.Price, ProductDate = DateTime.Today, Quantity = model.Quantity, CategoryId = model.CategoryId }; context.Products.Add(product); context.SaveChanges(); return(product.ProductId); } }
public int login(LoginModel model) { using (var context = new OnlineShopingEntities()) { string UserName = model.UserName.Replace(" ", ""); string Password = model.Password.Replace(" ", ""); int HashPassword = HashFunction(Password); var user = context.Users.Where(x => x.UserName == UserName && x.Password == HashPassword).FirstOrDefault(); if (user != null) { return(user.UserId); } else { return(-1); } } }
public int InsertUserInfo(UserInformation model, string UserName) { using (var context = new OnlineShopingEntities()) { var user = context.Users.Where(x => x.UserName == UserName).FirstOrDefault(); UserInformation userInformation = new UserInformation() { Name = model.Name, Address = model.Address, PhoneNumber = model.PhoneNumber, Email = model.Email, UserId = user.UserId }; context.UserInformations.Add(userInformation); context.SaveChanges(); return(userInformation.UserInfoId); } }
public int UpdateProduct(ProductPriceUpdateModel model) { using (var context = new OnlineShopingEntities()) { var product = context.Products.Where(x => x.ProductId == model.ProductId).FirstOrDefault(); if (product != null) { product.Price = model.price; } else { return(-1); } context.SaveChanges(); return(product.ProductId); } }
public ActionResult UpdatePriceInfo(ProductPriceUpdateModel model) { if (ModelState.IsValid) { int id = productUpdateOperation.UpdateProduct(model); if (id > 0) { ModelState.Clear(); ViewBag.Success = "Updated!"; } else { ViewBag.Success = "Failed!"; } } ProductPriceUpdateModel productPriceUpdateModel = new ProductPriceUpdateModel(); using (var context = new OnlineShopingEntities()) { productPriceUpdateModel.products = context.Products.ToList(); } return(View(productPriceUpdateModel)); }
public ActionResult InsertProductInfo(ProductModel model) { if (ModelState.IsValid) { int id = insertDetails.InsertProduct(model); if (id > 0) { ModelState.Clear(); ViewBag.Success = "Inserted successfull"; } else { ViewBag.Success = "Failed!"; } } ProductModel productModel = new ProductModel(); using (var context = new OnlineShopingEntities()) { productModel.categories = context.Categories.ToList(); } return(View(productModel)); }