public ActionResult Save(String ID) { int id = 0; if (ID != "0") { id = Convert.ToInt32(Helpers.CommonMethods.Decrypt(HttpUtility.UrlDecode(ID))); } Category category = new Category(); try { if (ModelState.IsValid) { Services.CategoryServiceClient categoryServiceClient = new Services.CategoryServiceClient(); category = categoryServiceClient.GetCategory(id); //ViewBag.Status = "Update"; } } catch (Exception e) { ModelState.AddModelError("error", "something went wrong"); category = null; throw e; } return(View("Save", category)); //return View(category); }
public ActionResult DeleteCategory(String ID) { int id = Convert.ToInt32(Helpers.CommonMethods.Decrypt(HttpUtility.UrlDecode(ID))); bool status = false; try { if (ModelState.IsValid) { Services.CategoryServiceClient categoryServiceClient = new Services.CategoryServiceClient(); status = categoryServiceClient.Delete(id); } } catch (Exception e) { ModelState.AddModelError("error", "Something Went Wrong!"); status = false; throw e; } return(View("Index")); //return new JsonResult { Data = new { status = status } }; }
public ActionResult Save(Category category) { bool status = false; try { if (ModelState.IsValid) { Services.CategoryServiceClient categoryServiceClient = new Services.CategoryServiceClient(); status = categoryServiceClient.SaveData(category); return(RedirectToAction("Index")); } } catch (Exception e) { ModelState.AddModelError("error", "Something Went Wrong"); status = false; throw e; } return(View(category)); //return View(); // return new JsonResult { Data = new { status = status } }; }