Esempio n. 1
0
        private bool CanChangeLeaveStatus(LeaveEntry leave, LeaveStatus leaveStatus, Employee actionEmployee)
        {
            switch (leaveStatus)
            {
            case LeaveStatus.Pending:
            case LeaveStatus.AwaitingDocumentation:     //Change
                return(true);

            case LeaveStatus.Approved:
                if (this.IsSickLeaveWithoutDocumentation(leave)) //Change
                {
                    return(false);                               //Change
                }
                return(leave.CurrentApprover.EmployeeId == actionEmployee.EmployeeId);

            case LeaveStatus.Finalized:
                if (this.IsSickLeaveWithoutDocumentation(leave)) //Change
                {
                    return(false);                               //Change
                }
                return(actionEmployee.IsManager());

            default:
                throw new ArgumentOutOfRangeException("leaveStatus");
            }
        }
Esempio n. 2
0
        public void CreateLeave(LeaveInputModel input)
        {
            LeaveEntry leave = new LeaveEntry
            {
                EmployeeId  = input.EmployeeId,
                StartDate   = input.StartDate,
                EndDate     = input.EndDate,
                LeaveType   = input.LeaveType,
                LeaveStatus = LeaveStatus.Pending,
            };
            var escalationList = this.GetApprovers(input.EmployeeId, input.LeaveType);

            leave.Approvers.AddRange(escalationList);
            leave.CurrentApprover = leave.Approvers.First();
            this.leaveRepository.Insert(leave);
        }
 private bool IsSickLeaveWithoutDocumentation(LeaveEntry leave)
 {
     return leave.Document == null && leave.LeaveType == LeaveType.Sick;
 }
 private bool CanChangeLeaveStatus(LeaveEntry leave, LeaveStatus leaveStatus, Employee actionEmployee)
 {
     switch(leaveStatus)
     {
         case LeaveStatus.Pending:
         case LeaveStatus.AwaitingDocumentation: //Change
             return true;
         case LeaveStatus.Approved:
             if (this.IsSickLeaveWithoutDocumentation(leave))//Change
             {
                 return false;//Change
             }
             return leave.CurrentApprover.EmployeeId == actionEmployee.EmployeeId;
         case LeaveStatus.Finalized:
             if (this.IsSickLeaveWithoutDocumentation(leave))//Change
             {
                 return false;//Change
             }
             return actionEmployee.IsManager();
         default:
             throw new ArgumentOutOfRangeException("leaveStatus");
     }
 }
 public void CreateLeave(LeaveInputModel input)
 {
     LeaveEntry leave = new LeaveEntry
                            {
                                EmployeeId = input.EmployeeId,
                                StartDate = input.StartDate,
                                EndDate = input.EndDate,
                                LeaveType = input.LeaveType,
                                LeaveStatus = LeaveStatus.Pending,
                             };
     var escalationList = this.GetApprovers(input.EmployeeId, input.LeaveType);
     leave.Approvers.AddRange(escalationList);
     leave.CurrentApprover = leave.Approvers.First();
     this.leaveRepository.Insert(leave);
 }
Esempio n. 6
0
 private bool IsSickLeaveWithoutDocumentation(LeaveEntry leave)
 {
     return(leave.Document == null && leave.LeaveType == LeaveType.Sick);
 }