async Task SendEmails(IEnumerable <SubzzV2.Core.Entities.User> users, Subzz.Integration.Core.Domain.Message message, AbsenceModel absenceModel)
        {
            if (absenceModel.IsApprovalRequired && absenceModel.SubstituteRequired)
            {
                foreach (var user in users)
                {
                    try
                    {
                        message.Password = user.Password;
                        message.UserName = user.FirstName;
                        message.SendTo   = user.Email;
                        //For Substitutes
                        if (user.RoleId == 4)
                        {
                            message.TemplateId = 1;
                            if (user.IsSubscribedEmail)
                            {
                                await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                            }
                            if (user.IsSubscribedSMS)
                            {
                                message.PhoneNumber = user.PhoneNumber;
                                CommunicationContainer.SMSProcessor.Process(message, (MailTemplateEnums)message.TemplateId);
                            }
                        }

                        else if (user.RoleId == 3)
                        {
                            message.TemplateId = 10;
                            if (user.IsSubscribedEmail)
                            {
                                await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                            }
                        }

                        //For Admins
                        else
                        {
                            message.TemplateId = 2;
                            if (user.IsSubscribedEmail)
                            {
                                await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
示例#2
0
 async Task SendRunningLateEmail(IEnumerable <SubzzV2.Core.Entities.User> users, Subzz.Integration.Core.Domain.Message message, AbsenceModel absenceDetail)
 {
     foreach (var user in users)
     {
         try
         {
             message.Password = user.Password;
             message.UserName = user.FirstName;
             message.SendTo   = user.Email;
             //For Admins And Substitutes
             if (user.RoleId != 4)
             {
                 message.TemplateId = 27;
                 if (user.IsSubscribedEmail)
                 {
                     await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                 }
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
示例#3
0
        async Task SendJobDeclinEmails(IEnumerable <SubzzV2.Core.Entities.User> users, Subzz.Integration.Core.Domain.Message message)
        {
            foreach (var user in users)
            {
                try
                {
                    message.Password = user.Password;
                    message.UserName = user.FirstName;
                    message.SendTo   = user.Email;
                    //For Substitutes
                    if (user.RoleId == 4)
                    {
                        //message.TemplateId = 1;
                        //await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                    }

                    else if (user.RoleId == 3)
                    {
                        if (user.IsSubscribedEmail)
                        {
                            message.TemplateId = 24;
                            await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        }
                    }
                    //For Admins
                    else
                    {
                        if (user.IsSubscribedEmail)
                        {
                            message.TemplateId = 23;
                            await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#4
0
        async Task SendJobAcceptEmails(IEnumerable <SubzzV2.Core.Entities.User> users, Subzz.Integration.Core.Domain.Message message, AbsenceModel absenceDetail)
        {
            foreach (var user in users)
            {
                try
                {
                    message.Password = user.Password;
                    message.UserName = user.FirstName;
                    message.SendTo   = user.Email;
                    //For Substitutes
                    if (user.RoleId == 4)
                    {
                        message.TemplateId = 12;
                        var grade          = _userService.GetGradeLevelsForNotification(user.UserId);
                        var isGradeEnabled = grade.Where(x => x.TeachingLevelId == absenceDetail.GradeId).FirstOrDefault();
                        var sub            = _userService.GetSubjectsForNotifications(user.UserId);
                        var subjects       = sub.Where(x => x.TeacherSpecialityId == absenceDetail.SpecialityTypeId).FirstOrDefault();
                        var cat            = _userService.GetSubstituteCategories(user.UserId);
                        var categories     = cat.Where(x => x.TypeId == absenceDetail.PositionId).FirstOrDefault();

                        if (user.IsSubscribedEmail && (isGradeEnabled != null ? isGradeEnabled.GradeNotification : true) &&
                            (subjects != null ? subjects.SubjectNotification : true) && (absenceDetail.OnlyCertified ? user.IsCertified == 1 : true) &&
                            (categories != null ? categories.IsNotificationSend : true))
                        {
                            if (absenceDetail.OrganizationId != "-1")
                            {
                                var subSchools      = _userService.GetSubstitutePreferredSchools(user.UserId);
                                var isSchoolEnabled = subSchools.Where(x => x.OrganizationId == absenceDetail.OrganizationId).First();
                                if (isSchoolEnabled.IsEnabled)
                                {
                                    await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                                }
                            }
                            else
                            {
                                await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                            }
                        }

                        if (user.IsSubscribedSMS && (isGradeEnabled != null ? isGradeEnabled.GradeNotification : true) &&
                            (subjects != null ? subjects.SubjectNotification : true) && (absenceDetail.OnlyCertified ? user.IsCertified == 1 : true) &&
                            (categories != null ? categories.IsNotificationSend : true))
                        {
                            message.PhoneNumber = user.PhoneNumber;
                            if (absenceDetail.OrganizationId != "-1")
                            {
                                var subSchools      = _userService.GetSubstitutePreferredSchools(user.UserId);
                                var isSchoolEnabled = subSchools.Where(x => x.OrganizationId == absenceDetail.OrganizationId).First();
                                if (isSchoolEnabled.IsEnabled)
                                {
                                    message.PhoneNumber = user.PhoneNumber;
                                    CommunicationContainer.SMSProcessor.Process(message, (MailTemplateEnums)message.TemplateId);
                                }
                            }
                            else
                            {
                                CommunicationContainer.SMSProcessor.Process(message, (MailTemplateEnums)message.TemplateId);
                            }
                        }
                        //if (user.IsSubscribedEmail)
                        //{
                        //    var sub = _userService.GetSubjectsForNotifications(user.UserId);
                        //    var subjects = sub.Where(x => x.TeacherSpecialityId == absenceDetail.SpecialityTypeId).FirstOrDefault();
                        //    if (absenceDetail.OnlySubjectSpecialist && subjects != null ? subjects.SubjectNotification : true &&
                        //        absenceDetail.OnlyCertified ? user.IsCertified == 1 : true)
                        //        await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        //}
                        //if (user.IsSubscribedSMS)
                        //{
                        //    message.PhoneNumber = user.PhoneNumber;
                        //    var sub = _userService.GetSubjectsForNotifications(user.UserId);
                        //    var subjects = sub.Where(x => x.TeacherSpecialityId == absenceDetail.SpecialityTypeId).FirstOrDefault();
                        //    if (absenceDetail.OnlySubjectSpecialist && subjects != null ? subjects.SubjectNotification : true &&
                        //        absenceDetail.OnlyCertified ? user.IsCertified == 1 : true)
                        //        CommunicationContainer.SMSProcessor.Process(message, (MailTemplateEnums)message.TemplateId);
                        //}
                    }

                    else if (user.RoleId == 3)
                    {
                        message.TemplateId = 11;
                        if (user.IsSubscribedEmail)
                        {
                            await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        }
                    }

                    //For Admins
                    else
                    {
                        message.TemplateId = 3;
                        if (user.IsSubscribedEmail)
                        {
                            await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#5
0
        public async Task SendNotificationsOnJobApprovedOrDenied(LeaveRequestModel leave)
        {
            AbsenceModel absenceDetail = _absenceService.GetAbsenceDetailByAbsenceId(Convert.ToInt32(leave.AbsenceId));

            Subzz.Integration.Core.Domain.Message message = new Subzz.Integration.Core.Domain.Message();
            message.AbsenceId = absenceDetail.AbsenceId;
            message.StartTime = DateTime.ParseExact(Convert.ToString(absenceDetail.StartTime), "HH:mm:ss",
                                                    CultureInfo.InvariantCulture).ToSubzzTime();
            message.EndTime = DateTime.ParseExact(Convert.ToString(absenceDetail.EndTime), "HH:mm:ss",
                                                  CultureInfo.InvariantCulture).ToSubzzTime();
            message.StartDate      = Convert.ToDateTime(absenceDetail.StartDate).ToString("D");
            message.EndDate        = Convert.ToDateTime(absenceDetail.EndDate).ToString("D");
            message.EmployeeName   = absenceDetail.EmployeeName;
            message.Position       = absenceDetail.PositionDescription;
            message.Subject        = absenceDetail.SubjectDescription;
            message.Grade          = absenceDetail.Grade;
            message.Location       = absenceDetail.AbsenceLocation;
            message.Notes          = absenceDetail.SubstituteNotes;
            message.SubstituteName = absenceDetail.SubstituteName;
            message.Reason         = absenceDetail.AbsenceReasonDescription;
            message.ApprovedBy     = _userService.GetUserDetail(leave.ApprovedBy).FirstName;
            message.Duration       = absenceDetail.DurationType == 1 ? "Full Day" : absenceDetail.DurationType == 2 ? "First Half" : absenceDetail.DurationType == 3 ? "Second Half" : "Custom";
            var user = _userService.GetUserDetail(absenceDetail.EmployeeId);

            if (leave.IsApproved)
            {
                message.TemplateId = 16;
            }
            else
            {
                message.TemplateId = 19;
            }
            message.Photo = absenceDetail.EmployeeProfilePicUrl;
            try
            {
                message.Password = user.Password;
                message.UserName = user.FirstName;
                message.SendTo   = user.Email;
                await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
            }
            catch (Exception ex)
            {
            }

            if (leave.IsApproved)
            {
                IEnumerable <SubzzV2.Core.Entities.User> users = _userService.GetAdminListByAbsenceId(Convert.ToInt32(leave.AbsenceId));
                foreach (var User in users)
                {
                    try
                    {
                        message.Password = User.Password;
                        message.UserName = User.FirstName;
                        message.SendTo   = User.Email;
                        //For Substitutes
                        if (User.RoleId == 4)
                        {
                            message.TemplateId = 1;
                            await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        }
                        else if (User.RoleId == 3)
                        {
                            message.TemplateId = 10;
                            await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        }
                        //For Admins
                        else
                        {
                            message.TemplateId = 2;
                            await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
示例#6
0
        public async Task SendJobAcceptEmails(IEnumerable <SubzzV2.Core.Entities.User> users, Subzz.Integration.Core.Domain.Message message)
        {
            foreach (var User in users)
            {
                try
                {
                    message.Password = User.Password;
                    message.UserName = User.FirstName;
                    message.SendTo   = User.Email;
                    //For Substitutes
                    if (User.RoleId == 4)
                    {
                        message.TemplateId = 1;
                        await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                    }

                    if (User.RoleId == 3)
                    {
                        message.TemplateId = 11;
                        await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                    }

                    //For Admins
                    else
                    {
                        message.TemplateId = 3;
                        await CommunicationContainer.EmailProcessor.ProcessAsync(message, (MailTemplateEnums)message.TemplateId);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }