public ActionResult AddBelt(Belt belt) { try { if (!ModelState.IsValid) { return(View("AddBelt", belt)); } else { BeltBL beltBL = new BeltBL(); HttpPostedFileBase file = Request.Files["imageFile"]; if (file != null && file.ContentLength > 0) { belt.ProductImage = file.FileName; file.SaveAs(HttpContext.Server.MapPath("../Images/") + belt.ProductImage); } beltBL.AddBelt(belt); return(RedirectToAction("BeltList")); } } catch (Exception e) { Console.WriteLine(e.Message); return(View()); } }
public ActionResult BeltList() { BeltListVM beltListVM = new BeltListVM(); BeltBL beltBL = new BeltBL(); List <Belt> beltList = new List <Belt>(); beltListVM.BeltVMList = BeltList2BeltVMList(beltBL.GetBeltList()); return(View(beltListVM)); }
public ActionResult EditBelt(Belt belt) { try { BeltBL beltBL = new BeltBL(); beltBL.EditBelt(belt.BeltId, belt.Name, belt.Cost, belt.Description); return(RedirectToAction("BeltList")); } catch { return(View()); } }
//public ActionResult DeleteBelt() //{ // return View(); //} //[HttpPost] public ActionResult DeleteBelt(Belt belt) { try { BeltBL beltBL = new BeltBL(); beltBL.DeleteBelt(belt.BeltId); return(RedirectToAction("BeltList")); } catch { return(View()); } }