public ActionResult DeleteConfirmed(int id) { IwanttobuyProduct iwanttobuyProduct = db.IwanttobuyProducts.Find(id); db.IwanttobuyProducts.Remove(iwanttobuyProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ProductPK,ProductType,ProductName,Quantity,Price,Description,ImgName,ImgPath,CreateDate,LastUpdate")] IwanttobuyProduct iwanttobuyProduct) { if (ModelState.IsValid) { iwanttobuyProduct.LastUpdate = DateTime.Now.AddHours(7); db.Entry(iwanttobuyProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(iwanttobuyProduct)); }
// GET: IwanttobuyProducts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IwanttobuyProduct iwanttobuyProduct = db.IwanttobuyProducts.Find(id); if (iwanttobuyProduct == null) { return(HttpNotFound()); } return(View(iwanttobuyProduct)); }
public ActionResult Search() { IwanttobuyProduct iwanttobuyProduct = new IwanttobuyProduct(); iwanttobuyProduct.ProductName = Request["txtSearch"].ToString(); if (iwanttobuyProduct.ProductName == "") { return(View("Index", db.IwanttobuyProducts.OrderBy(m => m.Price).ToList())); } ModelState.Clear(); int value; if (int.TryParse(Request["txtSearch"].ToString(), out value)) { iwanttobuyProduct.Price = value; return(View("Index", db.IwanttobuyProducts.Where(m => m.Price == iwanttobuyProduct.Price).ToList())); } return(View("Index", db.IwanttobuyProducts.Where(m => m.ProductName.Contains(iwanttobuyProduct.ProductName) || m.ProductType.Contains(iwanttobuyProduct.ProductName)).ToList())); }