public ActionResult AddWatch(Watch watch) { try { if (!ModelState.IsValid) { return(View("AddWatch", watch)); } else { WatchBL watchBL = new WatchBL(); HttpPostedFileBase file = Request.Files["imageFile"]; if (file != null && file.ContentLength > 0) { watch.ProductImage = file.FileName; file.SaveAs(HttpContext.Server.MapPath("~/Images/") + watch.ProductImage); } watchBL.AddWatch(watch); return(RedirectToAction("WatchList")); } } catch { return(View()); } }
public ActionResult WatchList() { WatchListVM watchListVM = new WatchListVM(); WatchBL watchBL = new WatchBL(); List <Watch> watchList = new List <Watch>(); watchListVM.WatchVMList = WatchList2WatchVMList(watchBL.GetWatchList()); return(View(watchListVM)); }
//public ActionResult DeleteWatch() //{ // return View(); //} //[HttpPost] public ActionResult DeleteWatch(Watch watch) { try { WatchBL watchBL = new WatchBL(); watchBL.DeleteWatch(watch.WatchId); return(RedirectToAction("WatchList")); } catch { return(View()); } }
public ActionResult EditWatch(Watch watch) { try { WatchBL watchBL = new WatchBL(); watchBL.EditWatch(watch.WatchId, watch.Name, watch.Cost, watch.Description); return(RedirectToAction("WatchList")); } catch { return(View()); } }