public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page, int gradeId)
        {
            ViewBag.gradeId = gradeId;
            _viewMessageLogic.SetViewMessageIfExist();
            var temp = _pensumRepository.Filter(x => x.Grade.Id == gradeId).ToList();

            ViewBag.gradeName = _gradeRepository.GetById(gradeId).Name;

            ViewBag.CurrentSort    = sortOrder;
            ViewBag.CourseSortParm = string.IsNullOrEmpty(sortOrder) ? "course_desc" : "";
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            if (!string.IsNullOrEmpty(searchString))
            {
                temp = _pensumRepository.Filter(x => x.Name.Contains(searchString)).ToList();
            }
            var list = temp.Select(Mapper.Map <PensumDisplayModel>).OrderBy(s => s.Name).ToList();

            ViewBag.CurrentFilter = searchString;
            const int pageSize   = 10;
            var       pageNumber = (page ?? 1);

            return(View(list.ToPagedList(pageNumber, pageSize)));
        }
Beispiel #2
0
        public ActionResult Edit(long id)
        {
            var item       = _academicGradeRepository.GetById(id);
            var toReturn   = Mapper.Map <AcademicGradeEditModel>(item);
            var user       = _userRepository.GetById(Convert.ToInt64(_sessionManagementService.GetUserLoggedId()));
            var isDirector = user.Role.Name.Equals("Director");

            ViewBag.Grades = isDirector
                ? new SelectList(
                _gradeRepository.Filter(
                    x => x.EducationLevel.Director != null && x.EducationLevel.Director.Id == user.Id), "Id", "Name", item.Grade)
                : new SelectList(_gradeRepository.GetAllGrade(), "Id", "Name", item.Grade);
            ViewBag.Pensums = new SelectList(_pensumRepository.Filter(x => x.Grade.Id == item.Grade.Id), "Id", "Name", item.ActivePensum).ToList();
            return(View(toReturn));
        }
Beispiel #3
0
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            var message = (MessageModel)TempData["MessageInfo"];

            if (message != null)
            {
                ViewBag.MessageType    = message.Type;
                ViewBag.MessageTitle   = message.Title;
                ViewBag.MessageContent = message.Content;
            }
            var temp = _pensumRepository.GetAllPesums();

            ViewBag.CurrentSort    = sortOrder;
            ViewBag.CourseSortParm = String.IsNullOrEmpty(sortOrder) ? "course_desc" : "";
            ViewBag.GradeSortParm  = sortOrder == "Grade" ? "grade_desc" : "Grade";
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            if (!String.IsNullOrEmpty(searchString))
            {
                temp = _pensumRepository.Filter(x => x.Course.Name.Contains(searchString)).ToList();
            }
            var list = temp.Select(item => item.Course != null ? new DisplayPensumModel
            {
                Id     = item.Id,
                Course = item.Course.Name,
                Grade  = item.Grade.Name
            } : null).ToList();

            ViewBag.CurrentFilter = searchString;
            switch (sortOrder)
            {
            case "course_desc":
                list = list.OrderByDescending(s => s.Course).ToList();
                break;

            case "Grade":
                list = list.OrderBy(s => s.Grade).ToList();
                break;

            case "grade_desc":
                list = list.OrderByDescending(s => s.Grade).ToList();
                break;

            default:      // Name ascending
                list = list.OrderBy(s => s.Course).ToList();
                break;
            }
            const int pageSize   = 10;
            var       pageNumber = (page ?? 1);

            return(View(list.ToPagedList(pageNumber, pageSize)));
        }
Beispiel #4
0
        public ActionResult Delete(long id)
        {
            var check = _pensumRepository.Filter(x => x.Course.Id == id).FirstOrDefault();

            if (check == null)
            {
                var          course  = _courseRepository.Delete(id);
                const string title   = "Materia Eliminada";
                var          content = course.Name + " ha sido eliminado exitosamente.";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
                return(RedirectToAction("Index"));
            }
            else
            {
                const string title   = "Error!";
                var          content = "No se puede borrar la materia pues existe un pensum con esta materia.";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Details(long id)
        {
            var pensums = _pensumRepository.Filter(x => x.Grade.Id == id).Select(Mapper.Map <PensumDisplayModel>);

            return(View(pensums));
        }