public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page) { _viewMessageLogic.SetViewMessageIfExist(); var user = _userRepository.GetById(Convert.ToInt64(_sessionManagementService.GetUserLoggedId())); ViewBag.IsDirector = user.Role.Name.Equals("Director"); var grades = (bool)ViewBag.IsDirector ? _gradeRepository.Filter( x => x.EducationLevel.Director != null && x.EducationLevel.Director.Id == user.Id) : _gradeRepository.GetAllGrade(); ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = string.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.EducationLevelSortParam = sortOrder == "education_asc" ? "education_desc" : "education_asc"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } if (!String.IsNullOrEmpty(searchString)) { grades = ((bool)ViewBag.IsDirector ? _gradeRepository.Filter( x => x.EducationLevel.Director != null && x.EducationLevel.Director.Id == user.Id) : _gradeRepository.GetAllGrade()).Where(x => x.Name.Contains(searchString)).ToList(); } var displayGradeModels = grades.Select(Mapper.Map <Grade, GradeDisplayModel>).ToList(); ViewBag.CurrentFilter = searchString; switch (sortOrder) { case "education_desc": displayGradeModels = displayGradeModels.OrderByDescending(s => s.EducationLevel).ToList(); break; case "education_asc": displayGradeModels = displayGradeModels.OrderBy(s => s.EducationLevel).ToList(); break; case "name_desc": displayGradeModels = displayGradeModels.OrderByDescending(s => s.Name).ToList(); break; default: // Name ascending displayGradeModels = displayGradeModels.OrderBy(s => s.EducationLevel).ToList(); break; } const int pageSize = 10; var pageNumber = (page ?? 1); return(View(displayGradeModels.ToPagedList(pageNumber, pageSize))); }
public ActionResult Index(long yearId, string currentFilter, string searchString, int?page) { _viewMessageLogic.SetViewMessageIfExist(); var user = _userRepository.GetById(Convert.ToInt64(_sessionManagementService.GetUserLoggedId())); var isDirector = ViewBag.IsDirector = user.Role.Name.Equals("Director"); var grades = isDirector ? _academicGradeRepository.Filter( x => x.AcademicYear.Id == yearId && x.Grade.EducationLevel.Director != null && x.Grade.EducationLevel.Director.Id == user.Id).ToList() : _academicGradeRepository.Filter(x => x.AcademicYear.Id == yearId).ToList(); ViewBag.IdAcademicYear = yearId; ViewBag.Year = _academicYearRepository.GetById(yearId).Year; if (searchString != null) { page = 1; } else { searchString = currentFilter; } if (!string.IsNullOrEmpty(searchString)) { try { grades = isDirector ? _academicGradeRepository.Filter( x => x.AcademicYear.Id == yearId && x.Grade.EducationLevel.Director != null && x.Grade.EducationLevel.Director.Id == user.Id && (x.Section.Equals(searchString) || x.Grade.Name.Contains(searchString))).ToList() : _academicGradeRepository.Filter( x => x.AcademicYear.Id == yearId && (x.Section.Equals(searchString) || x.Grade.Name.Contains(searchString))).ToList(); } catch (Exception) { grades = isDirector ? _academicGradeRepository.Filter( x => x.AcademicYear.Id == yearId && x.Grade.EducationLevel.Director != null && x.Grade.EducationLevel.Director.Id == user.Id).ToList() : _academicGradeRepository.Filter(x => x.AcademicYear.Id == yearId).ToList(); } } ViewBag.CurrentFilter = searchString; var model = grades.Select(Mapper.Map <AcademicGradeDisplayModel>); const int pageSize = 10; var pageNumber = (page ?? 1); return(View(model.ToPagedList(pageNumber, pageSize))); }
// // GET: /MyAccount/ public ActionResult Index() { _viewMessageLogic.SetViewMessageIfExist(); var userId = Convert.ToInt64(_sessionManagementService.GetUserLoggedId()); var user = _userRepository.GetById(userId); var myaccountmodel = new AccountEditModel() { Id = user.Id, Email = user.Email }; return(View(myaccountmodel)); }
public ActionResult Index() { _viewMessageLogic.SetViewMessageIfExist(); var importModel = new DataImportModel(); var user = _userRepository.GetById(Convert.ToInt64(_sessionManagementService.GetUserLoggedId())); var isDirector = ViewBag.IsDirector = user.Role.Name.Equals("Director"); ViewBag.GradeId = isDirector ? new SelectList(_gradeRepository.Filter(x => x.EducationLevel.Director != null && x.EducationLevel.Director.Id == user.Id).ToList(), "Id", "Name", 0) : new SelectList(_gradeRepository.GetAllGrade(), "Id", "Name", 0); ViewBag.Year = new SelectList(_academicYearRepository.Filter(x => x.EnrollsOpen), "Id", "Year"); ViewBag.Section = new List <SelectListItem>(); return(View(importModel)); }
public ActionResult Index(string sortOrder, string currentFilter, int?page) { ViewBag.GradeId = -1; _viewMessageLogic.SetViewMessageIfExist(); ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; var user = _userRepository.GetById(Convert.ToInt64(_sessionManagementService.GetUserLoggedId())); var isDirector = user.Role.Name.Equals("Director"); var grades = isDirector ? _academicGradeRepository.Filter( x => x.AcademicYear.IsActive && x.Grade.EducationLevel.Director != null && x.Grade.EducationLevel.Director.Id == user.Id).ToList() : _academicGradeRepository.Filter(x => x.AcademicYear.IsActive).ToList(); if (!grades.Any()) { return(View(new List <EnrollDisplayModel>().ToPagedList(1, 10))); } var model = new List <EnrollDisplayModel>(); foreach (var academicGrade in grades) { model.AddRange(academicGrade.Students.Select(n => new EnrollDisplayModel { AcademicGradeId = academicGrade.Id, StudentId = n.Id, FullName = n.FullName, Photo = n.Photo, MyGender = n.MyGender.ToString("G"), AccountNumber = n.AccountNumber, Grade = academicGrade.Grade.Name, Section = academicGrade.Section })); } switch (sortOrder) { case "name_desc": model = model.OrderByDescending(s => s.FullName).ToList(); break; default: // Name ascending model = model.OrderBy(s => s.FullName).ToList(); break; } const int pageSize = 10; var pageNumber = (page ?? 1); return(View(model.ToPagedList(pageNumber, pageSize))); }
public ActionResult UpdateEmail(UpdateTutorMailModel model) { var userId = Convert.ToInt64(_sessionManagementService.GetUserLoggedId()); var tutorUser = _tutorRepository.Filter(x => x.User.Id == userId).Include(x => x.User).FirstOrDefault(); if (tutorUser != null) { var user = tutorUser.User; user.Email = model.Email; _userRepository.Update(user); return(RedirectToAction("Index", "Notification")); } return(RedirectToAction("ConfirmEmail")); }
public ActionResult Index() { var id = _sessionManagement.GetUserLoggedId(); if (id == "") { return(RedirectToAction("Index", "Login")); } ViewBag.DoctorName = _sessionManagement.GetUserLoggedName(); return(View()); }
public ActionResult Index(string searchName, int?page) { _viewMessageLogic.SetViewMessageIfExist(); var loggedUser = _userRepository.GetById(Convert.ToInt64(_sessionManagement.GetUserLoggedId())); var roleName = loggedUser.Role.Name; var notifications = new List <Notification>(); if (roleName.Equals("Administrador")) { notifications = _notificationRepository.Filter(personal => personal.NotificationType == NotificationType.Personal) .OrderByDescending(x => x.CreationDate).ToList(); } else if (roleName.Equals("Director")) { var academicGrade = _academicGradeRepository.Filter( x => x.Grade.EducationLevel.Director != null && x.Grade.EducationLevel.Director.Id == loggedUser.Id && x.SectionTeacher != null).ToList(); var teachersIds = academicGrade.Select(x => x.SectionTeacher.User.Id).Distinct().ToList(); notifications = _notificationRepository.Filter(personal => personal.NotificationType == NotificationType.Personal && teachersIds.Any( x => personal.To != null && personal.To.User.Id == x)).ToList(); } else { notifications = _notificationRepository.Filter(personal => personal.NotificationType == NotificationType.Personal && personal.To != null && personal.To.User.Email == loggedUser.Email) .OrderByDescending(x => x.CreationDate) .ToList(); } if (!string.IsNullOrWhiteSpace(searchName)) { notifications = notifications.ToList().FindAll(x => x.Title.Contains(searchName)); } ViewBag.RoleName = roleName; var notificationsModel = notifications.Select(Mapper.Map <PersonalMessageDisplayModel>); const int pageSize = 10; var pageNumber = page ?? 1; return(View(notificationsModel.ToPagedList(pageNumber, pageSize))); }
public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page) { _viewMessageLogic.SetViewMessageIfExist(); var user = _userRepository.GetById(Convert.ToInt64(_sessionManagementService.GetUserLoggedId())); ViewBag.IsDirector = user.Role.Name.Equals("Director"); var allAcademicYears = _academicYearRepository.GetAllAcademicYears(); ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "year_desc" : ""; if (searchString != null) { page = 1; } else { searchString = currentFilter; } if (!string.IsNullOrEmpty(searchString)) { try { var year = Convert.ToInt32(searchString); allAcademicYears = _academicYearRepository.Filter(x => x.Year.Equals(year)); } catch (Exception) { allAcademicYears = _academicYearRepository.GetAllAcademicYears(); } } var academicYears = allAcademicYears.Select(Mapper.Map <AcademicYearDisplayModel>).ToList(); ViewBag.CurrentFilter = searchString; switch (sortOrder) { case "year_desc": academicYears = academicYears.OrderByDescending(s => s.Year).ToList(); break; default: // Name ascending academicYears = academicYears.OrderBy(s => s.Year).ToList(); break; } const int pageSize = 10; var pageNumber = (page ?? 1); return(View(academicYears.ToPagedList(pageNumber, pageSize))); }
public ActionResult ChangePassword(ChangePasswordModel model) { if (!ModelState.IsValid) { return(View()); } var userId = Convert.ToInt32(_sessionManagementService.GetUserLoggedId()); var user = _userRepository.GetById(userId); user.Password = model.NewPassword; user.HashPassword(); user.DefaultPassword = null; user.IsUsingDefaultPassword = false; _userRepository.Update(user); return(RedirectToAction("Index", "Home")); }
public ActionResult Index(string searchName, int?page) { _viewMessageLogic.SetViewMessageIfExist(); var user = _userRepository.GetById(Convert.ToInt64(_sessionManagement.GetUserLoggedId())); var isDirector = user.Role.Name.Equals("Director"); var isAdmin = user.Role.Name.Equals("Administrador"); var notifications = new List <Notification>(); if (isAdmin) { notifications = _notificationRepository.Filter(personal => personal.NotificationType != NotificationType.Personal).ToList(); } else if (isDirector) { notifications.AddRange( _notificationRepository.Filter(x => x.NotificationType == NotificationType.General)); var educationLevel = _educationLevelRepository.Filter(x => x.Director != null && x.Director.Id == user.Id).FirstOrDefault(); if (educationLevel != null) { notifications.AddRange( _notificationRepository.Filter( x => x.NotificationType == NotificationType.EducationLevel && x.DestinationId == educationLevel.Id)); var gradeIds = educationLevel.Grades.Select(x => x.Id); notifications.AddRange(_notificationRepository.Filter(x => x.NotificationType == NotificationType.Grade && gradeIds.Contains(x.DestinationId))); var academicGradeIds = _academicGradeRepository.Filter(x => gradeIds.Contains(x.Grade.Id)).Select(x => x.Id); notifications.AddRange(_notificationRepository.Filter(x => x.NotificationType == NotificationType.Section && academicGradeIds.Contains(x.DestinationId))); var courseIds = _academicCourseRepository.Filter(x => academicGradeIds.Contains(x.AcademicGrade.Id)).Select(x => x.Id); notifications.AddRange(_notificationRepository.Filter(x => x.NotificationType == NotificationType.Course && courseIds.Contains(x.DestinationId))); var tutorIds = _studentRepository.Filter(x => x.MyGrade != null && academicGradeIds.Contains(x.MyGrade.Id)) .Select(x => x.Tutor1.Id); notifications.AddRange(_notificationRepository.Filter(x => x.NotificationType == NotificationType.Student && tutorIds.Contains(x.DestinationId))); } } else { notifications = _notificationRepository.Filter(x => x.NotificationCreator.Id == user.UserOwner.Id).ToList(); } if (!string.IsNullOrWhiteSpace(searchName)) { notifications = notifications.ToList().FindAll(x => x.Title.Contains(searchName)); } var notificationsModel = notifications.OrderByDescending(i => i.CreationDate).Select(Mapper.Map <NotificationDisplayModel>); const int pageSize = 10; var pageNumber = (page ?? 1); return(View(notificationsModel.ToPagedList(pageNumber, pageSize))); }
private long GetTeacherId() { return(Convert.ToInt64(_sessionManagement.GetUserLoggedId())); }