public ActionResult DeleteConfirmed(int id) { var enrollee = _enrolleeService.Get(id); var statuses = enrollee.StudentStatuses.Where(s => s.FacultyStatus == false && s.Enrollee.Email == enrollee.Email).ToList(); var faculties = enrollee.Faculties.Where(f => f.StudentStatuses.Any(s => s.FacultyStatus == false)).ToList(); faculties.ForEach(f => enrollee.Faculties.Remove(f)); statuses.ForEach(s => enrollee.StudentStatuses.Remove(s)); statuses.ForEach(s => _studentStatusService.Delete(s.Id)); _enrolleeService.Update(enrollee); var statements = _statementService.GetAll(); if (!statements.Any() | !statements.Last().Enrollee.Contains(enrollee)) { return(RedirectToAction("GetStatement", "Statement", new { area = "Operator" })); } var statement = _statementService.GetAll().Last(); statement.Enrollee.Remove(enrollee); _statementService.Update(statement); return(RedirectToAction("GetEnrollees", "Enrollee", new { area = "Operator" })); }
public ActionResult AddedStudentDelete(int id, int facultyid) { var enrolee = _enrolleeService.Get(id); var faculty = enrolee.Faculties.First(f => f.Id == facultyid); if (enrolee.Faculties.Count == 1 && enrolee.Faculties.First().Id == facultyid) { var statement = _statementService.Find(s => s.Enrollee.Count(e => e.Faculties.Contains(faculty) && e.Id == enrolee.Id) > 0).First(); enrolee.Faculties.Remove(faculty); var status = enrolee.StudentStatuses.Where(s => s.Faculty.FacultyNumber == faculty.FacultyNumber && s.Enrollee.Email == enrolee.Email).First(); enrolee.StudentStatuses.Remove(status); statement.Enrollee.Remove(enrolee); _studentStatusService.Delete(status.Id); _enrolleeService.Update(enrolee); _statementService.Update(statement); } else { var status = enrolee.StudentStatuses.Where(s => s.Faculty.FacultyNumber == faculty.FacultyNumber && s.Enrollee.Email == enrolee.Email).First(); enrolee.StudentStatuses.Remove(status); enrolee.Faculties.Remove(faculty); _studentStatusService.Delete(status.Id); _enrolleeService.Update(enrolee); } return(RedirectToAction("GetAllAddedStudent", "Statement", new { area = "Operator" })); }
public ActionResult FacultyDelete(int id) { var faculty = _facultyService.Get(id); if (faculty == null) { return(HttpNotFound()); } var currentEnrollee = _enrolleeService.Find(customer => customer.AppCustomer.UserName == User.Identity.Name).First(); currentEnrollee.Faculties.Remove(faculty); var status = currentEnrollee.StudentStatuses.Where(s => s.Faculty.FacultyNumber == faculty.FacultyNumber && s.Enrollee.Email == currentEnrollee.Email).ToList(); status.ForEach(s => currentEnrollee.StudentStatuses.Remove(s)); status.ForEach(s => _studentStatusService.Delete(s.Id)); _enrolleeService.Update(currentEnrollee); return(RedirectToAction("GetFaculties", new { controller = "Enrolle", area = "Enrollee" })); }
public void SendMessageForAddedStudents() { var statement = _unitOfWork.StatementGenericRepository.GetAll().Last(); foreach (var faculty in _unitOfWork.FacultyGenericRepository.GetAll().Where(f => f.StudentStatuses.Any(s => s.FacultyStatus == false))) { var budget = GetBudget(statement, faculty); _logger.Info("Sending E-mails to budget students"); foreach (var item1 in budget) { if (faculty.Enrollees.Where(e => e.Email == item1.Email).All(e => e.Added != true)) { var notAdded = item1.Faculties.First(f => f.FacultyNumber == faculty.FacultyNumber); if (notAdded != null) { SendEmail(item1.Id, faculty.Name, "Budget Place"); var status = item1.StudentStatuses.First(s => s.Faculty.FacultyNumber == faculty.FacultyNumber); status.Status = "Budget"; status.FacultyStatus = true; _studentStatusService.Update(status); _unitOfWork.FacultyGenericRepository.Update(faculty); _unitOfWork.EnrolleeGenericRepository.Update(item1); } } } var contract = GetContract(statement, faculty); _logger.Info("Sending E-mails to contract students"); foreach (var item1 in contract) { if (faculty.Enrollees.Where(e => e.Email == item1.Email).All(e => e.Added != true)) { var notAdded = item1.Faculties.First(f => f.FacultyNumber == faculty.FacultyNumber); if (notAdded != null) { SendEmail(item1.Id, faculty.Name, "Contract Place"); var status = item1.StudentStatuses.First(s => s.Faculty.FacultyNumber == faculty.FacultyNumber); status.Status = "Contract"; status.FacultyStatus = true; _studentStatusService.Update(status); _unitOfWork.FacultyGenericRepository.Update(faculty); _unitOfWork.EnrolleeGenericRepository.Update(item1); } } } } var count = statement.Enrollee.Count(); for (int i = 0; i < count; i++) { if (statement.Enrollee.ToArray()[i].StudentStatuses.Any(s => s.FacultyStatus != true)) { var status = statement.Enrollee.ToArray()[i].StudentStatuses.Where(s => s.FacultyStatus != true).ToList(); foreach (var item in status) { statement.Enrollee.ToArray()[i].StudentStatuses.Remove(item); statement.Enrollee.ToArray()[i].Faculties.Remove(item.Faculty); _studentStatusService.Delete(item.Id); } } } statement.IsEnrolled = true; _unitOfWork.StatementGenericRepository.Update(statement); }