public ActionResult Get(int id) { var apiResult = TryExecute(() => _leaveRepository.Get(id, "CreatedByUser.Person,RequestedForUser.User.Person,Approver.User.Person,LeaveType"), "Leave fetched sucessfully"); var json = JsonConvert.SerializeObject(apiResult, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(Content(json, "application/json")); }
public bool Reject(int leaveId, int approverId, string approverComments) { var leave = _leaveRepository.Get(leaveId); leave.Status = LeaveStatus.Rejected; leave.ApproverId = approverId; leave.ApproverComments = approverComments; leave.ActedOn = DateTime.UtcNow; _leaveRepository.Update(leave); _unitOfWork.Commit(); return(true); }
public async Task <IActionResult> UpdateLeaves(int id, [FromBody] LeaveResource LeaveResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var Leaves = await _repo.Get(id); if (Leaves == null) { return(NotFound()); } _mapper.Map <LeaveResource, Leaves>(LeaveResource, Leaves); await _unitofwork.CompleteAsync(); return(StatusCode(202)); }
// GET: api/Leaves public IEnumerable <Leave> Get() { return(_leaveRepository.Get()); }
public bool CheckIsExist(Leave leave) { return(leaveRepository.Get(chk => chk.EmployeeId == leave.EmployeeId && chk.LeaveTypeId == leave.LeaveTypeId && chk.StartDate == leave.StartDate && chk.EndDate == leave.EndDate) == null ? false : true); }
public List <Leave> Get() { return(_leaveRepository.Get()); }
public Task <Leave> Get(int id) { return(_repo.Get(id)); }