public ActionResult Add(NotificationRegisterModel eventNotification) { eventNotification.NotificationCreator = _userRepository.GetById(Convert.ToInt64(_sessionManagement.GetUserLoggedId())).UserOwner.Id; eventNotification.AcademicYear = _academicYearRepository.GetCurrentAcademicYear().Id; var notificationIdentity = Mapper.Map <Notification>(eventNotification); var approved = _sessionManagement.GetUserLoggedRole().Equals("Administrador"); notificationIdentity.Approved = approved; notificationIdentity.PeopleDirectedTo = GetDestinationName(notificationIdentity); notificationIdentity = _notificationRepository.Create(notificationIdentity); var users = _userRepository.Filter(x => x.Role.Name == "Administrador"); if (!approved) { foreach (var user in users) { MailgunEmailService.SendEmailToUser(user, MessageService.ApproveMessage()); } } _notificationHandlerService.SendAllPending(); const string title = "Notificación Agregada"; var content = "La notificacion " + notificationIdentity.Title + " ha sido agregada exitosamente."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage); return(RedirectToAction("Index")); }