public async Task CreateLeaveInfo(Leave leave) { var leaderMaxLevel = _approvalRuleDomainService.GetLeaderMaxLevel( leave.Applicant.PersonType, leave.Type.ToString(), leave.GetDuration()); var approver = _personDomainService.FindFirstApprover(leave.Applicant.PersonId, leaderMaxLevel); await _leaveDomainService.CreateLeave(leave, leaderMaxLevel, Approver.FromPerson(approver)); }
public static ApprovalRule GetByLeave(Leave leave) { var approvalRule = new ApprovalRule(); approvalRule.PersonType = leave.Applicant.PersonType; approvalRule.LeaveType = leave.Type.ToString(); approvalRule.Duration = leave.GetDuration(); return(approvalRule); }
public static Leave ToDO(LeaveDTO dto) { var historyApprovalInfoDTOList = new List <ApprovalInfo>(); foreach (var historyApprovalInfoDTO in dto.HistoryApprovalInfoDTOList) { historyApprovalInfoDTOList.Add(ApprovalInfoAssembler.ToDO(historyApprovalInfoDTO)); } var leave = new Leave() { Id = dto.LeaveId, Applicant = ApplicantAssembler.ToDO(dto.ApplicantDTO), Approver = ApproverAssembler.ToDO(dto.ApproverDTO), CurrentApprovalInfo = ApprovalInfoAssembler.ToDO(dto.CurrentApprovalInfoDTO), HistoryApprovalInfos = historyApprovalInfoDTOList, StartTime = string.IsNullOrEmpty(dto.StartTime) ? DateTime.Now : DateTime.Parse(dto.StartTime), EndTime = string.IsNullOrEmpty(dto.EndTime) ? DateTime.Now : DateTime.Parse(dto.EndTime), MaxLeaderLevel = dto.MaxLeaderLevel }; leave.Duration = leave.GetDuration(); return(leave); }