Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
 // GET: api/Leaves
 public IEnumerable <Leave> Get()
 {
     return(_leaveRepository.Get());
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 public List <Leave> Get()
 {
     return(_leaveRepository.Get());
 }
Ejemplo n.º 7
0
 public Task <Leave> Get(int id)
 {
     return(_repo.Get(id));
 }