Beispiel #1
0
        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);
        }