예제 #1
0
        private async Task SendRequestApproval(LeaveRequest leaveRequest,
                                               PersonWithStaff requestedBy,
                                               PersonWithStaff supervisor,
                                               LeaveUseage leaveUseage)
        {
            //this is a list of substitutions avalible in the email template
            //these are used when notifying the approving supervisor of leave
            //$LEAVE-SUBSTITUTIONS$
            var substituions = new Dictionary <string, string>
            {
                { ":type", leaveRequest.Type.ToString() },
                { ":approve", $"{_settings.BaseUrl}/api/leaveRequest/approve/{leaveRequest.Id}" },
                { ":firstName", supervisor.PreferredName + " " + supervisor.LastName },
                { ":requester", requestedBy.PreferredName + " " + requestedBy.LastName },
                { ":start", leaveRequest.StartDate.ToString("MMM d yyyy") },
                { ":end", leaveRequest.EndDate.ToString("MMM d yyyy") },
                { ":time", $"{leaveRequest.Days} Day(s)" },
                { ":left", $"{leaveUseage.Left} Day(s)" }
            };

            await _emailService.SendTemplateEmail(substituions,
                                                  $"{requestedBy.PreferredName} Leave request approval",
                                                  EmailTemplate.RequestLeaveApproval,
                                                  requestedBy,
                                                  supervisor);
        }
예제 #2
0
 public bool ShouldNotifyHr(LeaveRequest leaveRequest, LeaveUseage leaveUseage)
 {
     if (leaveRequest.Type == LeaveType.Other)
     {
         return(true);
     }
     return(leaveUseage.Left < leaveRequest.Days);
 }
예제 #3
0
 public async Task <PersonExtended> ResolveLeaveRequestChain(LeaveRequest leaveRequest,
                                                             PersonWithStaff requestedBy,
                                                             OrgGroupWithSupervisor department,
                                                             OrgGroupWithSupervisor devision,
                                                             OrgGroupWithSupervisor supervisorGroup,
                                                             LeaveUseage leaveUseage)
 {
     return(await DoNotifyWork(leaveRequest, requestedBy, department, leaveUseage) ??
            await DoNotifyWork(leaveRequest, requestedBy, devision, leaveUseage) ??
            await DoNotifyWork(leaveRequest, requestedBy, supervisorGroup, leaveUseage));
 }
예제 #4
0
 private async Task NotifyHr(LeaveRequest leaveRequest, PersonWithStaff requestedBy, LeaveUseage leaveUseage)
 {
     if (!ShouldNotifyHr(leaveRequest, leaveUseage))
     {
         return;
     }
     //this is a list of substitutions avalible in the email template
     //these are used when notifying HR of leave
     //$LEAVE-SUBSTITUTIONS$
     var substituions = new Dictionary <string, string>
     {
         { ":type", leaveRequest.Type.ToString() },
         { ":requester", requestedBy.PreferredName + " " + requestedBy.LastName },
         { ":start", leaveRequest.StartDate.ToString("MMM d yyyy") },
         { ":end", leaveRequest.EndDate.ToString("MMM d yyyy") },
         { ":time", $"{leaveRequest.Days} Day(s)" },
         { ":left", $"{leaveUseage.Left} Day(s)" }
     };
     await _emailService.SendTemplateEmail(substituions,
                                           $"{requestedBy.PreferredName} has requested leave",
                                           EmailTemplate.NotifyHrLeaveRequest,
                                           requestedBy,
                                           _personRepository.GetHrAdminStaff());
 }
예제 #5
0
        private async ValueTask <PersonWithStaff> DoNotifyWork(LeaveRequest leaveRequest,
                                                               PersonWithStaff requestedBy,
                                                               OrgGroupWithSupervisor orgGroup, LeaveUseage leaveUseage)
        {
            //super and requested by will be the same if the requester is a supervisor
            if (orgGroup == null || requestedBy.Id == orgGroup.Supervisor)
            {
                return(null);
            }
            if (orgGroup.ApproverIsSupervisor && orgGroup.SupervisorPerson != null)
            {
                await SendRequestApproval(leaveRequest, requestedBy, orgGroup.SupervisorPerson, leaveUseage);

                return(orgGroup.SupervisorPerson);
            }

            if (orgGroup.SupervisorPerson != null)
            {
                await NotifyOfLeaveRequest(leaveRequest, requestedBy, orgGroup.SupervisorPerson, leaveUseage);
            }

            return(null);
        }