/// <summary> /// Creates or updates a catagory. Returns the created or updated catagory /// </summary> /// <param name="catagory">The catagory to create or update</param> public Category CreateUpdateCatagory(Category catagory) { if (catagory == null) { return null; } if (catagory.CategoryID == 0) { _mediaManagerContext.Entry(catagory).State = EntityState.Added; } else { _mediaManagerContext.Entry(catagory).State = EntityState.Modified; } try { _mediaManagerContext.SaveChanges(); } catch (Exception e) { throw e; } return catagory; }
public ActionResult Edit(Category category) { if (ModelState.IsValid) { unitOfWork.CategoryRepository.Update(category); unitOfWork.Save(); return RedirectToAction("Index"); } return View(category); }
public ActionResult CreateCatagory(Category category) { if (ModelState.IsValid) { _mediaService.CreateUpdateCatagory(category); return RedirectToAction("Catagories"); } InitializeView("Category"); return View(category); }