public ActionResult AddReportingResources(ResourceReportingAddDto model) { if (UserRoles.UserCanEdit() == true) { if (ModelState.IsValid) { bool isupdated = CandidateService.AddReportingResources(model); if (isupdated) { //return new JsonResult { Data = "The update has been successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Candidates"); return(Json(new { Url = redirectUrl })); } else { return new JsonResult { Data = "The update is not successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } return(View(model)); } else { return(RedirectToAction("Index", "Candidates")); } }
public static bool AddReportingResources(ResourceReportingAddDto model) { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(TimeSheetAPIURl); HttpResponseMessage response = client.PostAsJsonAsync(string.Format("Resource/AddReportingResources"), model).Result; if (response.IsSuccessStatusCode) { HttpContext.Current.Session["SuccessMessage"] = "Changes Updated Successfully !"; return(true); } else { HttpContext.Current.Session["ErrorMessage"] = "Unable To Update The Changes Please validate !"; } } return(false); }