//create leave request public async Task <LeaveRequestCreateResponse> CreateLeaveRequestAsync(LeaveRequestCreateRequest request) { var leave = _mapper.Map <Request>(request); _context.LeaveRequests.Add(leave); await _context.SaveChangesAsync(); return(_mapper.Map <LeaveRequestCreateResponse>(leave)); }
public async Task <IActionResult> CreateLeaveAsync([FromBody] LeaveRequestCreateRequest request) { if (!ModelState.IsValid) { throw new ServiceException(400, "Model is invalid"); } request.MemberName = Request.Headers["X-Forwarded-Username"]; request.MemberEmail = Request.Headers["X-Forwarded-Email"]; return(Ok(await _leaveService.CreateLeaveRequestAsync(request))); }