public ActionResult Update(int id = 0) { AppUser appUser = (AppUser)Session["LoggedUser"]; if (appUser != null) { Category category = categoryOperation.GetById(id); if (category != null) { CategoryCRUDModel categoryCRUDModel = new CategoryCRUDModel(); categoryCRUDModel.CategoryId = category.CategoryId; categoryCRUDModel.Name = category.Name; return(View(categoryCRUDModel)); } else { return(RedirectToAction("Index", "Category")); } } else { return(RedirectToAction("Login", "Home")); } }
public ActionResult Update(CategoryCRUDModel model) { if (Session["LoggedUser"] != null) { Category category = categoryOperation.GetById(model.CategoryId); category.CategoryId = model.CategoryId; category.Name = model.Name; categoryOperation.Update(category); } return(RedirectToAction("Index", "Category")); }
public ActionResult Insert(CategoryCRUDModel model) { AppUser appUser = (AppUser)Session["LoggedUser"]; if (appUser != null) { Category category = new Category() { AppUserId = appUser.AppUserId, CategoryId = model.CategoryId, Name = model.Name, IsActive = true }; categoryOperation.Insert(category); return(RedirectToAction("Index", "Category")); } else { return(RedirectToAction("Login", "Home")); } }