Beispiel #1
0
        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, 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)));
        }
Beispiel #3
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"));
        }
        public ActionResult Index()
        {
            _viewMessageLogic.SetViewMessageIfExist();
            var importModel = new ImportDataModel();

            ViewBag.GradeId = new SelectList(_gradeRepository.Query(x => x), "Id", "Name", 0);
            ViewBag.Year    = new SelectList(_academicYearRepository.Filter(x => x.IsActive).Select(x => x.Year).Distinct().ToList());
            ViewBag.Section = new SelectList(new List <string> {
                "A", "B", "C"
            }, "A");
            return(View(importModel));
        }
Beispiel #5
0
        public ActionResult Delete(long id)
        {
            var check = _academicYearRepository.Filter(x => x.Grade.Id == id).FirstOrDefault();

            if (check == null)
            {
                var          grade   = _gradeRepository.Delete(id);
                const string title   = "Grado ha sido Eliminado";
                var          content = grade.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 el grado pues existe un año académico con este grado.";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            _viewMessageLogic.SetViewMessageIfExist();
            var allAcademicYears = _academicYearRepository.GetAllAcademicYears();

            ViewBag.CurrentSort   = sortOrder;
            ViewBag.NameSortParm  = String.IsNullOrEmpty(sortOrder) ? "year_desc" : "";
            ViewBag.GradeSortParm = sortOrder == "Grade" ? "grade_desc" : "Grade";
            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)).ToList();
                }
                catch (Exception)
                {
                    //ignore
                }
            }
            var academicYears = allAcademicYears.Select(academicYear => new DisplayAcademicYearModel
            {
                Id             = academicYear.Id,
                Year           = academicYear.Year,
                Section        = academicYear.Section,
                Approved       = academicYear.Approved,
                IsActive       = academicYear.IsActive,
                EducationLevel = academicYear.Grade.EducationLevel,
                Grade          = academicYear.Grade.Name
            }).ToList();

            ViewBag.CurrentFilter = searchString;
            switch (sortOrder)
            {
            case "year_desc":
                academicYears = academicYears.OrderByDescending(s => s.Year).ToList();
                break;

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

            case "grade_desc":
                academicYears = academicYears.OrderByDescending(s => s.Grade).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)));
        }