public ActionResult Edit(TasteCategoryDTO tasteCategory) { if (ModelState.IsValid) { tasteCategoryService.AddOrUpdate(tasteCategory); return(RedirectToAction("IndexHtmlAction")); } return(View("Edit")); }
public ActionResult Delete(int id) { try { TasteCategoryDTO tasteCategory = tasteCategoryService.Get(id); tasteCategoryService.Delete(tasteCategory); return(Json("OK")); } catch { return(Json("Error")); } }
public ActionResult DeletePhoto(int id) { try { TasteCategoryDTO tasteCategory = tasteCategoryService.Get(id); tasteCategory.TasteCategoryPathPhoto = null; tasteCategoryService.AddOrUpdate(tasteCategory); return(Json("OK")); } catch { return(Json("Error")); } }
public ActionResult UploadPhoto(HttpPostedFileBase fileUpload) { string Id = Request.Params["id"]; if (fileUpload != null) { TasteCategoryDTO tasteCategory = tasteCategoryService.Get(Convert.ToInt32(Id)); tasteCategory.TasteCategoryPathPhoto = "/Images/" + fileUpload.FileName; tasteCategoryService.AddOrUpdate(tasteCategory); } string path = Path.Combine(Server.MapPath("~/Images/"), fileUpload.FileName); fileUpload.SaveAs(path); return(RedirectToAction("Edit", "TasteCategory", new { id = Convert.ToInt32(Id) })); }