public async Task AddLeave(LeaveToAddDto leaveToAdd) { var leave = OutgoingMapper.AddLeaveMap(leaveToAdd); var soldier = await _soldierRepository.GetById(leaveToAdd.SoldierId); soldier.Status = leaveToAdd.Type; await _soldierRepository.UpdateSoldier(soldier); await _leaveRepository.AddLeave(leave); }
public async Task <IActionResult> AddLeave(AddLeaveViewModel addLeaveView) { try { ReturnResult result = await _leaveRepository.AddLeave(addLeaveView); return(Ok(result)); } catch (Exception x) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <IActionResult> AddLeave(LeaveResource LeaveResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var LeaveToAdd = _mapper.Map <LeaveResource, Leaves>(LeaveResource); _repo.AddLeave(LeaveToAdd); await _unitofwork.CompleteAsync(); return(StatusCode(201)); }
public async Task <IActionResult> Post(LeaveDtoForAdd leave) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (await _repo.LeaveExists(Convert.ToInt32(_LoggedIn_UserID), leave.FromDate, leave.ToDate)) { return(BadRequest(new { message = CustomMessage.RecordAlreadyExist })); } _response = await _repo.AddLeave(leave); return(Ok(_response)); }
public static async Task <HttpResponseMessage> ApplyLeave_StartWF( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req, [OrchestrationClient] DurableOrchestrationClient starter, [Inject] ILeaveRepository respository, ILogger log) { // Function input comes from the request content. var leavereq = await req.Content.ReadAsAsync <Leave>(); leavereq.WorkflowId = string.Empty; leavereq.LeaveID = Guid.NewGuid(); leavereq.LeaveStatus = LeaveStatus.Applied; var result = await respository.AddLeave(leavereq, log); if (result != -1) { string instanceId = await starter.StartNewAsync("OrchestrationFunction", leavereq); leavereq.WorkflowId = instanceId; var res = await respository.UpdateLeave(leavereq, log); log.LogInformation($"Started orchestration with ID = '{instanceId}'."); return(starter.CreateCheckStatusResponse(req, instanceId)); } else { //await starter.TerminateAsync(instanceId, "Unable to add Leave to DB"); return(new HttpResponseMessage { StatusCode = System.Net.HttpStatusCode.BadRequest, Content = new StringContent(@"{""errorMessage"":""Unable to save leave to Db""}") }); } }