public ActionResult FacultyEdit(int id) { var subjects = _facultySubjectService.GetAll(); var examSubjects = _examinationSubjectService.GetAll(); var checkTags = _mapper.Map <ICollection <CheckModel> >(subjects); var checkExamTags = _mapper.Map <ICollection <CheckExamSubjects> >(examSubjects); var faculty = _facultyService.Get(id); var editFaculty = _mapper.Map <EditFaculty>(faculty); foreach (var item in checkTags) { if (editFaculty.FacultySubjects.Any(subject => subject.Name == item.Subject?.Name)) { item.Checked = true; } } foreach (var item in checkExamTags) { if (editFaculty.ExaminationSubjects.Any(subject => subject.Name == item.Subject?.Name)) { item.Checked = true; } } editFaculty.CheckSubjects = checkTags; editFaculty.CheckExamSubjects = checkExamTags; return(View(editFaculty)); }
public ActionResult FacultyDetails(int id) { var faculty = _facultyService.Get(id); if (faculty == null) { return(HttpNotFound()); } return(View(faculty)); }
public ActionResult Create(int id) { var currentEnrollee = _enrolleeService.Find(customer => customer.AppCustomer.UserName == User.Identity.Name).First(); var faculty = _facultyService.Get(id); var addedFaculty = _facultyService.GetAll().Where(f => f.FacultyNumber == faculty.FacultyNumber && faculty.Enrollees.Any()).ToList(); if (currentEnrollee.Faculties.Any(f => f.FacultyNumber == faculty.FacultyNumber)) { ModelState.AddModelError("AddFaculty", "This faculty already added."); return(View()); } else if (addedFaculty.Any() && addedFaculty.First().Enrollees.Any() && addedFaculty.First().Enrollees.Count(e => e.StudentStatuses.Any(s => s.FacultyStatus == true && s.Faculty.FacultyNumber == faculty.FacultyNumber)) == faculty.AllPlaces) { ModelState.AddModelError("AddFaculty", "No places are there :("); return(View()); } else { currentEnrollee.ExaminationSubjects.Clear(); currentEnrollee.SchoolSubjects.Clear(); foreach (var item in _schoolSubjectsService.GetAll().ToList()) { if (!currentEnrollee.SchoolSubjects.Contains(item)) { currentEnrollee.SchoolSubjects.Add(item); } } var exSubjects = _examinationSubjectService.Find(e => e.Faculties.Any(f => f.FacultyNumber == faculty.FacultyNumber)).ToList(); foreach (var item in exSubjects) { if (!currentEnrollee.ExaminationSubjects.Any(s => s.Name == item.Name)) { currentEnrollee.ExaminationSubjects.Add(item); } } currentEnrollee.Faculties.Add(faculty); var status = new StudentStatus() { Faculty = faculty, FacultyStatus = false, Enrollee = currentEnrollee, Status = "Enrollee" }; _studentStatusService.Create(status); _enrolleeService.Update(currentEnrollee); return(View("Create", currentEnrollee)); } }
public async Task <IActionResult> Search([FromQuery] SearchModel model) { var result = await facultyService.Get(model); return(Ok(result)); }