Exemple #1
0
 public ActionResult Add(EnrollRegisterModel modelEnroll)
 {
     Student student = _studentRepository.GetById(modelEnroll.Id);
     List<AcademicYear> collection =
         _academicYearRepository.Filter(x => x.Grade.Id == modelEnroll.GradeId && x.Section.Equals(modelEnroll.Section)).ToList();
     if (collection.Count > 0 && student != null)
     {
         foreach (AcademicYear academicYear in collection)
         {
             var myEnroll = new Enroll
             {
                 AcademicYear = academicYear,
                 Student = student
             };
             _enrollRepository.Create(myEnroll);
         }
         const string title = "Estudiante Agregado";
         const string content = "El estudiante ha sido matriculado exitosamente.";
         _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
     }
     else
     {
         const string title = "Estudiante No Agregado";
         const string content = "El estudiante no se logro matricular.";
         _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
     }
     return RedirectToAction("Index");
 }
Exemple #2
0
 public Enroll Create(Enroll itemToCreate)
 {
     var enroll = _context.Enrolls.Add(itemToCreate);
     _context.Entry(enroll.AcademicYear).State = EntityState.Modified;
     _context.Entry(enroll.Student).State = EntityState.Modified;
     _context.SaveChanges();
     return enroll;
 }
Exemple #3
0
 public Enroll Update(Enroll itemToUpdate, bool academicYear, bool student)
 {
     if (academicYear)
     {
         _context.Entry(itemToUpdate.AcademicYear).State = EntityState.Modified;
     }
     if (student)
     {
         _context.Entry(itemToUpdate.Student).State = EntityState.Modified;
     }
     _context.SaveChanges();
     return itemToUpdate;
 }
Exemple #4
0
        public Enroll Update(Enroll itemToUpdate)
        {
            var enroll = GetById(itemToUpdate.Id);
            bool academicYear = false;
            bool student = false;

            if (enroll.AcademicYear != itemToUpdate.AcademicYear)
            {
                enroll.AcademicYear = itemToUpdate.AcademicYear;
                academicYear = true;
            }
            if (enroll.Student != itemToUpdate.Student)
            {
                enroll.Student = itemToUpdate.Student;
                student = true;
            }

            return Update(enroll, academicYear, student);
        }
Exemple #5
0
 public void Detach(Enroll enroll)
 {
     _context.Entry(enroll).State = EntityState.Detached;
 }