public IActionResult RejectRequest(string leaveRequestNo) { PostedLeaveRequestViewModel vmObj = new PostedLeaveRequestViewModel(); try { postedleaverequestcard obj = new postedleaverequestcard(); postedleaverequestcard_Filter[] filter = { new postedleaverequestcard_Filter { Field = postedleaverequestcard_Fields.Leave_Request_No, Criteria = leaveRequestNo } }; obj = Postedleaverequestcard_PortClientService() .ReadMultipleAsync(filter, "", 1) .GetAwaiter() .GetResult() .ReadMultiple_Result1 .FirstOrDefault(); vmObj = _mapper.Map <PostedLeaveRequestViewModel>(obj); } catch (Exception ex) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Exception Error", text = ex.Message, type = "error" }); } return(View(vmObj)); }
public IActionResult RecommendRequest(PostedLeaveRequestViewModel vmObj) { try { ModelState.Remove("Rejection_Remarks"); ModelState.Remove("Pay_Type"); if (ModelState.IsValid) { var postResult = Hrmgt_PortClientService() .RecommendleaverequestwebAsync(vmObj.Leave_Request_No) .GetAwaiter() .GetResult() .return_value; if (postResult == 200) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Recommend Leave Request", text = "Leave request recommended successfully.", type = "success" }); return(RedirectToAction(nameof(Index))); } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Recommend Leave Request", text = "Recommendation failed.", type = "error" }); } } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Recommend Leave Request", text = "Validation Error. Try Again.", type = "error" }); } } catch (Exception ex) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Exception Error", text = ex.Message, type = "error" }); } return(RedirectToAction(nameof(RecommendRequest), new { leaveRequestNo = vmObj.Leave_Request_No })); }
public IActionResult RejectRequest(PostedLeaveRequestViewModel vmObj) { try { ModelState.Remove("Pay_Type"); if (ModelState.IsValid) { var obj = _mapper.Map <postedleaverequestcard>(vmObj); PostedLeaveRequestCard.Update updateObj = new PostedLeaveRequestCard.Update { postedleaverequestcard = obj }; var result = Postedleaverequestcard_PortClientService() .UpdateAsync(updateObj) .GetAwaiter() .GetResult() .postedleaverequestcard; if (result != null) { var postResult = Hrmgt_PortClientService() .RejectleaverequestwebAsync(result.Leave_Request_No) .GetAwaiter() .GetResult() .return_value; if (postResult == 200) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Reject Leave Request", text = "Leave request rejected successfully.", type = "success" }); return(RedirectToAction(nameof(Index))); } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Reject Leave Request", text = "Reject details saved but rejection failed.", type = "error" }); } } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Reject Leave Request", text = "Posting reject details failed.", type = "error" }); } } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Reject Leave Request", text = "Validation Error. Try Again.", type = "error" }); } } catch (Exception ex) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Exception Error", text = ex.Message, type = "error" }); } return(RedirectToAction(nameof(RejectRequest), new { leaveRequestNo = vmObj.Leave_Request_No })); }