private string SetUserRole(string currentUser, string projectId, string approver) { //NOTE: Any changes to this code should be replicated in the class AMPServiceLayer, Method ReturnCurrentUserMemberOfGroup. The method is almost identical and has been included as part of the //redevelopment of Workflow to be a service. Once project becomes a 'service' there will be one method, probably sitting in a single utility class. //Are you the approver? if (currentUser == approver) { return("Approver"); } //Are you on the Team? //Get Current Team IEnumerable <Team> currentTeam = _ampRepository.GetTeam(projectId); if (IsTeamMember(currentUser, currentTeam)) { return("Team"); } else { return("Others"); } }
public async Task SetHoDAlertPeople(IAMPRepository ampRepository, IPersonService personService, string sender, string projectId) { if (string.IsNullOrWhiteSpace(sender)) { throw new ArgumentException("string is null or blank", "sender"); } if (string.IsNullOrWhiteSpace(projectId)) { throw new ArgumentException("string is null or blank", "projectId"); } //Get the list of HoD approvers for the project IEnumerable <vHoDBudCentLookup> HoDAlertPeople = ampRepository.GetHoDAlertRecipients(projectId); if (HoDAlertPeople == null) { throw new NullReferenceException("SetHodAlertPeople. Null returned for project " + projectId); } List <vHoDBudCentLookup> HodAlertPeopleOrderedList = HoDAlertPeople.OrderBy(x => x.GradeRank).ToList(); if (HodAlertPeopleOrderedList.Any()) { if (HodAlertPeopleOrderedList.Count() == 1) { vHoDBudCentLookup HodAlertLookUp = HodAlertPeopleOrderedList.FirstOrDefault(); if (HodAlertLookUp != null) { await SetRecipientEmail(personService, HodAlertLookUp.EmpNo); } } else { //Highest grade gets to be recipient. Everyone else is on the cc list. string recipientEmpNo = HodAlertPeopleOrderedList.First().EmpNo; List <String> ccEmpNoList = HodAlertPeopleOrderedList.Skip(1).Select(x => x.EmpNo).Distinct().ToList(); await SetRecipientEmail(personService, recipientEmpNo); await SetCCRecipients(personService, ccEmpNoList); } } else { throw new ArgumentOutOfRangeException("SetHodAlertPeople. No HoD alerts returned for project " + projectId); } IEnumerable <Team> projectTeam = ampRepository.GetTeam(projectId); await SetSRO(personService, projectTeam); await SetSenderEmail(personService, sender); }
public async Task SetEmailPeople(IAMPRepository ampRepository, IPersonService personService, string sender, string recipient, string projectId) { if (string.IsNullOrWhiteSpace(sender)) { throw new ArgumentException("string is null or blank", "sender"); } if (string.IsNullOrWhiteSpace(recipient)) { throw new ArgumentException("string is null or blank", "recipient"); } IEnumerable <Team> projectTeam = ampRepository.GetTeam(projectId); List <string> empNoList = projectTeam.Select(x => x.TeamID).Distinct().ToList(); await SetSenderEmail(personService, sender); await SetRecipientEmail(personService, recipient); await SetSRO(personService, projectTeam); await SetCCRecipients(personService, empNoList); }