예제 #1
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);
        }
예제 #2
0
        private bool CanChangeLeaveStatus(LeaveEntry leave, LeaveStatus leaveStatus, Employee actionEmployee)
        {
            switch (leaveStatus)
            {
            case LeaveStatus.Pending:
                return(true);

            case LeaveStatus.Approved:
                return(leave.CurrentApprover.EmployeeId == actionEmployee.EmployeeId);

            case LeaveStatus.Finalized:
                if (leave.LeaveStatus != LeaveStatus.Approved)
                {
                    throw new ArgumentException("Cannot Finalize Leave");
                }
                return(actionEmployee.IsManager());

            default:
                throw new ArgumentOutOfRangeException("leaveStatus");
            }
        }
 private bool CanChangeLeaveStatus(LeaveEntry leave, LeaveStatus leaveStatus, Employee actionEmployee)
 {
     switch(leaveStatus)
     {
         case LeaveStatus.Pending:
             return true;
         case LeaveStatus.Approved:
             return leave.CurrentApprover.EmployeeId == actionEmployee.EmployeeId;
         case LeaveStatus.Finalized:
             if(leave.LeaveStatus != LeaveStatus.Approved)
             {
                 throw new ArgumentException("Cannot Finalize Leave");
             }
             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);
 }