public ActionResult Delete(int ID) { BrandActionModel model = new BrandActionModel(); var brand = services.GetBrandByID(ID); model.BrandID = brand.BrandID; return(PartialView("_Delete", model)); }
public ActionResult AddAndEdit(int?ID) { BrandActionModel model = new BrandActionModel(); if (ID.HasValue) { var brand = services.GetBrandByID(ID.Value); model.BrandID = brand.BrandID; model.BrandName = brand.BrandName; } return(PartialView("_AddAndEdit", model)); }
public JsonResult Delete(BrandActionModel model) { JsonResult json = new JsonResult(); var result = false; var brand = services.GetBrandByID(model.BrandID); result = services.DeleteBrand(brand); if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform action on Main Menu" }; } return(json); }
public JsonResult AddAndEdit(BrandActionModel model) { JsonResult json = new JsonResult(); var result = false; if (model.BrandID > 0) { var brand = services.GetBrandByID(model.BrandID); brand.BrandName = model.BrandName; brand.UpdatedAt = DateTime.Now; result = services.UpdateBrand(brand); } else { Brand brand = new Brand(); brand.BrandName = model.BrandName; brand.UpdatedAt = DateTime.Now; result = services.SaveBrand(brand); } if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to perform action on Main Menu" }; } return(json); }