public void SendEmailToFirstStep(List <string> emails, AdminNotificationViewModel model) { var emailRequest = new EmailRequestWithUrl <AdminNotificationViewModel>() { Model = model }; emails.ForEach(x => emailRequest.To.Add(new System.Net.Mail.MailAddress(x))); _emailComposer.SendAdminProcessedEmail(emailRequest); }
public ActionResult AdminNotificationManager(string message = null) { ViewBag.message = message; var coursesQueue = _context.courseRepository.GetListOfCoursesQueue(); List <CourseQueueNotificationViewModel> notificationsCoursesQueue = new List <CourseQueueNotificationViewModel>(); foreach (var courseQueue in coursesQueue) { var course = _context.courseRepository.GetCourseById(courseQueue.CourseIdentificator); foreach (var awaitingUser in courseQueue.AwaitingUsers) { var user = _context.userRepository.GetUserById(awaitingUser.UserIdentificator); CourseQueueNotificationViewModel singleNotification = new CourseQueueNotificationViewModel { Course = _mapper.Map <DisplayCrucialDataCourseViewModel>(course), EnrolledUser = _mapper.Map <DisplayCrucialDataUserViewModel>(user), EnrollmentDate = awaitingUser.LogData.DateOfLogCreation, EnrollmentOlderThan2Weeks = false }; if (DateTime.Now.Subtract(singleNotification.EnrollmentDate).Days > 14) { singleNotification.EnrollmentOlderThan2Weeks = true; } notificationsCoursesQueue.Add(singleNotification); } } var notEndedCoursesAfterEndDate = _context.courseRepository.GetCoursesAfterEndDate(); List <DisplayCourseNotificationViewModel> notificationsNotEndedCourses = new List <DisplayCourseNotificationViewModel>(); foreach (var notEndedCourse in notEndedCoursesAfterEndDate) { DisplayCourseNotificationViewModel singleNotification = _mapper.Map <DisplayCourseNotificationViewModel>(notEndedCourse); notificationsNotEndedCourses.Add(singleNotification); } var adminLogs = _context.personalLogRepository.GetListOfAdminPersonalLogs(); List <DisplayLogInformationViewModel> overallLogs = new List <DisplayLogInformationViewModel>(); if (adminLogs != null) { foreach (var log in adminLogs.LogData) { DisplayLogInformationViewModel singleLog = _mapper.Map <DisplayLogInformationViewModel>(log); var changeAuthor = _context.userRepository.GetUserById(log.ChangeAuthorIdentificator); singleLog.ChangeAuthor = _mapper.Map <DisplayCrucialDataUserViewModel>(changeAuthor); overallLogs.Add(singleLog); } } AdminNotificationViewModel adminNotifications = new AdminNotificationViewModel { CourseQueueNotification = notificationsCoursesQueue, NotEndedCoursesAfterEndDate = notificationsNotEndedCourses, OverallLogs = overallLogs }; return(View(adminNotifications)); }