コード例 #1
0
        public ActionResult AddCommentToNotification(int notificationId, string commentText)
        {
            var loggedUserEmail = System.Web.HttpContext.Current.Session["loggedUserEmail"].ToString();

            _loggedTutor = _tutorRepository.Filter(y => y.User.Email == loggedUserEmail).FirstOrDefault();
            var selectedNotification = _notificationRepository.GetById(notificationId);

            selectedNotification.NotificationComments.Add(new NotificationComment
            {
                CommentText = commentText,
                Commenter   = _loggedTutor.User
            });
            _notificationRepository.Update(selectedNotification);
            var users = selectedNotification.RecipientUsers.ToList();

            foreach (var user in users)
            {
                if (!user.Email.Equals(loggedUserEmail))
                {
                    MailgunEmailService.SendEmailToUser(user, MessageService.ConstruirMensaje(user.Role, selectedNotification.Title));
                }
            }
            var creatorUser = selectedNotification.NotificationCreator.User;

            if (!loggedUserEmail.Equals(creatorUser.Email))
            {
                MailgunEmailService.SendEmailToUser(creatorUser, MessageService.ConstruirMensaje(creatorUser.Role, selectedNotification.Title));
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        public ActionResult SendNewMessage([Bind(Prefix = "Item2")] MessageToTeacherModel model)
        {
            if (HttpContext.Session != null)
            {
                var loggedUserEmail = System.Web.HttpContext.Current.Session["loggedUserEmail"].ToString();
                var loggedTutor     = _tutorRepository.Filter(y => y.User.Email == loggedUserEmail).FirstOrDefault();
                var teacher         = _teacherRepository.Filter(x => x.User.Email == model.To).ToList().FirstOrDefault();

                if (teacher == null)
                {
                    return(RedirectToAction("Index"));
                }
                var newNotification = new Notification(model.Subject, model.Message, loggedTutor, teacher,
                                                       NotificationType.Personal, _academicYearRepository.GetCurrentAcademicYear())
                {
                    Approved  = true,
                    SendEmail = true
                };
                newNotification.RecipientUsers.Add(teacher.User);
                _notificationRepository.Create(newNotification);
                MailgunEmailService.SendEmailToUser(teacher.User, MessageService.ConstruirMensaje(teacher.User.Role));
                ViewBag.Message = "Mensaje Enviado!";
            }
            else
            {
                ViewBag.Message = "Mensaje No Enviado!";
            }
            return(RedirectToAction("Index", "Notification", new { filter = "Personal" }));
        }
コード例 #4
0
        public ActionResult RecoverPassword(LostPasswordModel model)
        {
            var user = _userRepository.Filter(x => x.Email.Equals(model.Email)).FirstOrDefault();

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var password = _passwordGenerationService.GenerateTemporaryPassword();

            user.Password = password;
            user.HashPassword();
            user.DefaultPassword        = user.Password;
            user.IsUsingDefaultPassword = true;
            _userRepository.Update(user);
            MailgunEmailService.SendEmailToUser(user, MessageService.ChangePasswordMessage(password));
            return(RedirectToAction("LogIn", "Account"));
        }
コード例 #5
0
        public ActionResult Create(HomeworkRegisterModel registerModelHomework)
        {
            var toCreate  = Mapper.Map <Homework>(registerModelHomework);
            var teacherId = GetTeacherId();

            toCreate.AcademicCourse = _academicCourseRepository.Filter(x => x.Teacher != null && x.Teacher.User.Id == teacherId && x.Course.Id == registerModelHomework.Course).FirstOrDefault();
            _homeworkRepository.Create(toCreate);
            const string title   = "Tarea agregada";
            string       content = "La tarea " + toCreate.Title + " ha sido agregado exitosamente.";

            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
            var studentsTutors =
                _studentRepository.Filter(
                    x => x.MyGrade != null && x.MyGrade.CoursesDetails.Any(y => y.Id == toCreate.AcademicCourse.Id))
                .ToList();

            foreach (var studentTutor in studentsTutors)
            {
                var tutorUser = studentTutor.Tutor1.User;
                MailgunEmailService.SendEmailToUser(tutorUser, MessageService.NotificarTarea(toCreate.Title));
            }
            return(RedirectToAction("Index"));
        }