Ejemplo n.º 1
0
 public Notification Create(Notification itemToCreate)
 {
     foreach (var user in itemToCreate.Users)
     {
         _context.Users.Attach(user);
     }
     var notification = _context.Notifications.Add(itemToCreate);
     _context.SaveChanges();
     return notification;
 }
Ejemplo n.º 2
0
 public void Delete(Notification itemToDelete)
 {
     _context.Notifications.Remove(itemToDelete);
 }
Ejemplo n.º 3
0
 public Notification Update(Notification itemToUpdate)
 {
     _context.Entry(itemToUpdate).State = EntityState.Modified;
     return itemToUpdate;
 }
Ejemplo n.º 4
0
 private void AddUsersToPersonalNotification(Notification notificationIdentity)
 {
     var notificationParentId =
         _studentRepository.Filter(x => x.Id == notificationIdentity.IdGradeAreaUserGeneralSelected).Where(x => x.Tutor1 != null).Select(x => x.Tutor1).FirstOrDefault();
     if (notificationParentId != null)
     {
         var parents = _parentRepository.GetById(notificationParentId.Id);
         var user = parents.MyUser;
         if (user != null)
         {
             notificationIdentity.Users.Add(user);
             SendEmail.SendEmailToUsers(notificationIdentity.Users.ToList(),
                 "Se ha creado una notificacion en la cual usted ha sido incluido.Mensaje: " +
                 notificationIdentity.Message, "Notificacion creada");
         }
     }
 }
Ejemplo n.º 5
0
 private void AddUsersToLevelNotification(Notification notificationIdentity)
 {
     var area = _areaReporsitory.GetById(notificationIdentity.IdGradeAreaUserGeneralSelected);
     var grades = _gradeRepository.GetAllGrade().Where(x => x.EducationLevel.Equals(area.Name)).Select(x => x.Id).ToList();
     if (!grades.Any())
     {
         return;
     }
     foreach (var id in grades)
     {
         long id1 = id;
         var studentList = _enrollRepository.GetAllsEnrolls().Where(x => x.AcademicYear.Grade.Id == id1
                                                 && x.AcademicYear.Year == DateTime.Now.Year)
                                                 .Select(x => x.Student).ToList();
         if (!studentList.Any())
         {
             continue;
         }
         foreach (var student in studentList)
         {
             var student1 = student;
             var notificationParentId = _studentRepository.Query(x => x).Where(x => x.Id == student1.Id
                                                                 && x.Tutor1 != null)
                                                                 .Select(x => x.Tutor1).Include(x => x.MyUser)
                                                                 .FirstOrDefault();
             if (notificationParentId != null)
             {
                 if (notificationParentId.MyUser != null)
                 {
                     notificationIdentity.Users.Add(notificationParentId.MyUser);
                 }
             }
             notificationParentId = _studentRepository.GetAllStudents().Where(x => x.Id == student.Id
                                                         && x.Tutor2 != null && x.Tutor2 != x.Tutor1)
                                                         .Select(x => x.Tutor2).FirstOrDefault();
             if (notificationParentId != null)
             {
                 User parents = _userRepository.GetById(notificationParentId.MyUser.Id);
                 if (parents != null)
                 {
                     notificationIdentity.Users.Add(parents);
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 private void AddUsersToGradeNotification(Notification notificationIdentity)
 {
     var estudiantes = _enrollRepository.Query(x => x).Where(x => x.AcademicYear.Grade.Id == notificationIdentity.IdGradeAreaUserGeneralSelected
                                && x.AcademicYear.Year == DateTime.Now.Year).Select(s => s.Student).ToList();
     foreach (var estudiante in estudiantes)
     {
         if (estudiante.Tutor1.MyUser != null)
         {
             var parents = _userRepository.GetById(estudiante.Tutor1.MyUser.Id);
             if (parents != null)
             {
                 notificationIdentity.Users.Add(parents);
                 var parents2 = _userRepository.GetById(estudiante.Tutor2.MyUser.Id);
                 if (parents2 != null && parents2.Id != parents.Id)
                 {
                     notificationIdentity.Users.Add(parents2);
                 }
             }
         }
     }
 }