public ActionResult DeleteColor(int id) { bool status = false; try { if (ModelState.IsValid) { Services.ColorServiceClient colorServiceClient = new ColorServiceClient(); status = colorServiceClient.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 GetAllColor() { List <Color> color = new List <Color>(); try { if (ModelState.IsValid) { ColorServiceClient colorServiceClient = new ColorServiceClient(); color = colorServiceClient.GetAllColors(); if (color.Count == 0 || color == null) { ModelState.AddModelError("error", "No Record Found"); } } } catch (Exception e) { ModelState.AddModelError("error", "Something Wrong"); color = null; throw e; } return(Json(new { data = color }, JsonRequestBehavior.AllowGet)); }
public HomeController(ILogger <HomeController> logger, ColorServiceClient colorServiceClient) { this._colorServiceClient = colorServiceClient; _logger = logger; }