public ActionResult Edit(products products) { var p = context.products.Where(s => s.ID.Equals(products.ID)).FirstOrDefault(); context.products.Remove(p); context.products.Add(products); context.SaveChanges(); return(RedirectToAction("Details", "product", new { id = products.ID })); }
public ActionResult Review(Models.ProductReview review) { // if valid, add to db and redirect back to Product page if (ModelState.IsValid) { db.ProductReviews.Add(review); db.SaveChanges(); return(RedirectToAction("IndividualProduct", new { id = review.ProductID })); } // return prepopulated model back to user if not valid review.Product = db.Products.Find(review.ProductID); return(View(review)); }
public ActionResult Delete(int num_no) { try { var model = db.Reviews.Find(num_no); db.Reviews.Remove(model); db.SaveChanges(); ModelState.AddModelError("", "Deleted"); } catch { ModelState.AddModelError("", "Error"); } return(RedirectToAction("Index")); }
public static void Regiter(string Email, string Pass) { string Id = Services.IDServices.RandomIDUser(); var Use = context.Users.Where(s => s.ID.Equals(Id)).FirstOrDefault(); while (Use != null) { Id = Services.IDServices.RandomIDUser(); } Models.Users user = new Models.Users(); user.Email = Email; user.Passwords = Pass; user.ID = Id; context.Users.Add(user); context.SaveChanges(); }
public static void AddProduct(string Name, int?Amout, double?Price, string Image, string Des) { string Id = Services.IDServices.RandomIDProduct(); var product = context.products.Where(s => s.ID.Equals(Id)).FirstOrDefault(); while (product != null) { Id = Services.IDServices.RandomIDUser(); } Models.products products = new Models.products(); products.ID = Id; products.name_product = Name; products.price = Price; products.amount = Amout; products.file_names = Image; products.Descriptions = Des; context.products.Add(products); context.SaveChanges(); }