public async Task <IActionResult> ApprovalRequest(StatusRequestVM statusRequestVM) { var response = await httpClient.PostAsJsonAsync("Request/SubmitApproved", statusRequestVM); string apiResponse = await response.Content.ReadAsStringAsync(); var data = JsonConvert.DeserializeObject <StatusRequestVM>(apiResponse); return(Json(data)); }
public async Task <JsonResult> Reject(StatusRequestVM statusRequestVM) { StringContent content = new StringContent(JsonConvert.SerializeObject(statusRequestVM), Encoding.UTF8, "application/json"); var response = await httpClient.PutAsync("Request/SubmitRejected", content); string apiResponse = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <StatusRequestVM>(apiResponse); return(new JsonResult(result)); }
public ActionResult SubmitRejected(StatusRequestVM statusRequest) { var data = repository.Rejected(statusRequest); if (data == 1) { return(Ok(new { status = "Your request Rejected" })); } else { return(StatusCode(500, new { status = "Internal Server Error" })); } }
public int Approved(StatusRequestVM request) { var data = myContext.Requests.Where(r => r.Id == request.Id).FirstOrDefault(); if (data == null) { return(0); } else if (data.RequestStatus == RequestStatus.RejectByManager || data.RequestStatus == RequestStatus.RejectByHRD) { return(0); } if (data.RequestStatus == RequestStatus.OnProcess) { data.RequestStatus = RequestStatus.ApprovedByManager; data.ApprovedManager = "Approved"; myContext.Update(data); var request2 = new GeneralDapperRepository <RequestVM>(_configuration); _parameters.Add("@RoleId", 4); //role HR var result2 = request2.Query("SP_sendEmailHR", _parameters); var emailHR = result2.Email; SendEmail.Approvemanager(emailHR, data); } else if (data.RequestStatus == RequestStatus.ApprovedByManager) { var totoalDays = (data.EndDate.AddDays(1) - data.StartDate).TotalDays; var dataQuota = myContext.Requests.Where(e => e.Id == request.Id).FirstOrDefault(); dataQuota.Employee.RemainingQuota -= Convert.ToInt32(totoalDays); //kondisi cuti hamil myContext.Update(dataQuota); myContext.SaveChanges(); data.RequestStatus = RequestStatus.ApprovedByHRD; data.ApprovedHRD = "Approved"; myContext.Update(data); var request3 = new GeneralDapperRepository <RequestVM>(_configuration); var param = request.Id; _parameters.Add("@Id", param); var result3 = request3.Query("SP_EmailEmployee", _parameters); var emailEmployee = result3.Email; SendEmail.ApproveHR(emailEmployee, data); } myContext.SaveChanges(); return(1); }
public int Rejected(StatusRequestVM request) { var data = myContext.Requests.Where(r => r.Id == request.Id).FirstOrDefault(); if (data == null) { return(0); } else if (data.RequestStatus == RequestStatus.OnProcess) { data.RequestStatus = RequestStatus.RejectByManager; data.ApprovedManager = "Rejected"; myContext.Update(data); var request1 = new GeneralDapperRepository <RequestVM>(_configuration); var temp = request.Id; _parameters.Add("@Id", temp); var result2 = request1.Query("SP_EmailEmployee", _parameters); var emailEmployee = result2.Email; SendEmail.Rejected(emailEmployee, request.RejectedNotes, data); } else if (data.RequestStatus == RequestStatus.ApprovedByManager) { data.RequestStatus = RequestStatus.RejectByHRD; data.ApprovedManager = "Rejected"; myContext.Update(data); var request1 = new GeneralDapperRepository <RequestVM>(_configuration); var temp = request.Id; _parameters.Add("@Id", temp); var result2 = request1.Query("SP_EmailEmployee", _parameters); var emailEmployee = result2.Email; SendEmail.Rejected(emailEmployee, request.RejectedNotes, data); } else { return(0); } myContext.SaveChanges(); return(1); }