public ActionResult Create(Products model) { try { if (ModelState.IsValid) { var obj = new FileUploadHelper(); var filename = obj.SaveImages(); if (filename == obj.ErrorMessage) { ModelState.AddModelError("ImageUpload Error", filename); return View(model); } model.ImageUrl = filename; ObjProductService.Add(model); return RedirectToAction("Index"); } else { return View(model); } } catch { return View(); } }
public ActionResult Edit(int id, Products product) { try { if (ModelState.IsValid) { ObjProductService.Update(product); return RedirectToAction("Index"); } return View(product); } catch { return View(); } }
public void Delete(Products entity) { repository.Delete(entity); unitOfWork.Commit(); }
public Products Update(Products entity) { entity = repository.Update(entity); unitOfWork.Commit(); return entity; }
public Products Add(Products entity) { entity = repository.Add(entity); unitOfWork.Commit(); return entity; }