Ejemplo n.º 1
0
        public ActionResult Edit(long id)
        {
            Homework thisHomework = _homeworkRepository.GetById(id);
            var      homework     = Mapper.Map <HomeworkEditModel>(thisHomework);
            var      teacherId    = GetTeacherId();
            var      detalleAnhosAcademicosActivos = _academicCourseRepository.GetAllAcademicYearDetails().ToList().FindAll(x => x.AcademicGrade.AcademicYear.IsActive);
            var      detallesFilteredByTeacher     = detalleAnhosAcademicosActivos.FindAll(x => x.Teacher != null && x.Teacher.Id == teacherId);
            var      query = detallesFilteredByTeacher.Select(detail => detail.Course).ToList();

            ViewBag.course = new SelectList(query, "Id", "Name");
            ViewBag.Years  = DateTimeController.GetYears();
            ViewBag.Months = DateTimeController.GetMonths();
            ViewBag.Days   = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View("Edit", homework));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(long id)
        {
            var admin      = _peopleWithUserRepository.GetById(id);
            var adminModel = Mapper.Map <PeopleWithUser, AdministrativeEditModel>(admin);
            var items      = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
            {
                Text  = c.GetEnumDescription(),
                Value = c.ToString("D")
            }).ToList();

            ViewBag.Genders = new List <SelectListItem>(items);
            ViewBag.Years   = DateTimeController.GetYears();
            ViewBag.Months  = DateTimeController.GetMonths();
            ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View("Edit", adminModel));
        }
Ejemplo n.º 3
0
        public ActionResult Add()
        {
            var items = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
            {
                Text  = c.GetEnumDescription(),
                Value = c.ToString("D")
            }).ToList();

            ViewBag.Genders = new List <SelectListItem>(items);
            ViewBag.Years   = DateTimeController.GetYears();
            ViewBag.Months  = DateTimeController.GetMonths();
            ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View("Create", new TeacherRegisterModel {
                Year = ((KeyValuePair <int, int>)((SelectList)ViewBag.Years).SelectedValue).Value
            }));
        }
Ejemplo n.º 4
0
        public ActionResult Add()
        {
            ViewBag.Roles = new SelectList(_roleRepository.Filter(x => x.Name.Equals("Administrador") || x.Name.Equals("Director")), "Id", "Name");
            var items = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
            {
                Text  = c.GetEnumDescription(),
                Value = c.ToString("D")
            }).ToList();

            ViewBag.Genders = new List <SelectListItem>(items);
            ViewBag.Years   = DateTimeController.GetYears();
            ViewBag.Months  = DateTimeController.GetMonths();
            ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View("Create", new AdministrativeRegisterModel {
                Year = ((KeyValuePair <int, int>)((SelectList)ViewBag.Years).SelectedValue).Value
            }));
        }
Ejemplo n.º 5
0
        public ActionResult Add()
        {
            _viewMessageLogic.SetViewMessageIfExist();
            ViewBag.Tutor1Id = new SelectList(_tutorRepository.Query(x => x).OrderBy(x => x.FullName), "Id", "FullName");
            var items = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
            {
                Text  = c.GetEnumDescription(),
                Value = c.ToString("D")
            }).ToList();

            ViewBag.Genders = new List <SelectListItem>(items);
            ViewBag.Years   = DateTimeController.GetYears();
            ViewBag.Months  = DateTimeController.GetMonths();
            ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View("Create", new StudentRegisterModel {
                Year = ((KeyValuePair <int, int>)((SelectList)ViewBag.Years).SelectedValue).Value
            }));
        }
Ejemplo n.º 6
0
        public ActionResult Create()
        {
            var teacherId = GetTeacherId();
            var courses   =
                _academicCourseRepository.Filter(
                    x => x.AcademicGrade.AcademicYear.IsActive && x.Teacher != null && x.Teacher.Id == teacherId)
                .Select(x => x.Course);

            ViewBag.course = new SelectList(courses, "Id", "Name");
            ViewBag.Years  = DateTimeController.GetYears();
            ViewBag.Months = DateTimeController.GetMonths();
            ViewBag.Days   = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            var modelRegister = new HomeworkRegisterModel {
                Year = ((KeyValuePair <int, int>)((SelectList)ViewBag.Years).SelectedValue).Value
            };

            return(View(modelRegister));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(long id)
        {
            var student      = _studentRepository.GetById(id);
            var studentModel = Mapper.Map <Student, StudentEditModel>(student);

            ViewBag.Tutor1Id = new SelectList(_tutorRepository.Query(x => x).OrderBy(x => x.FullName), "Id", "FullName",
                                              studentModel.Tutor1);
            var items = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
            {
                Text  = c.GetEnumDescription(),
                Value = c.ToString("D")
            }).ToList();

            ViewBag.Genders = new List <SelectListItem>(items);
            ViewBag.Years   = DateTimeController.GetYears();
            ViewBag.Months  = DateTimeController.GetMonths();
            ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View("Edit", studentModel));
        }
Ejemplo n.º 8
0
        public ActionResult Edit(StudentEditModel modelStudent)
        {
            var validImageTypes = new []
            {
                "image/gif",
                "image/jpeg",
                "image/pjpeg",
                "image/png"
            };

            if (modelStudent.FilePicture != null && modelStudent.FilePicture.ContentLength > 0)
            {
                if (!validImageTypes.Contains(modelStudent.FilePicture.ContentType))
                {
                    ModelState.AddModelError("FilePicture", "Por favor seleccione entre una imagen GIF, JPG o PNG");
                }
            }
            if (ModelState.IsValid)
            {
                if (
                    _studentRepository.Filter(x => (x.IdNumber.Equals(modelStudent.IdNumber) || x.AccountNumber.Equals(modelStudent.AccountNumber)) && x.Id != modelStudent.Id)
                    .Any())
                {
                    const string title   = "Error!";
                    const string content = "Ya existe un estudiante con ese número de identidad o de cuenta.";
                    _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
                    return(RedirectToAction("Index"));
                }
                try
                {
                    if (modelStudent.FilePicture != null)
                    {
                        using (var binaryReader = new BinaryReader(modelStudent.FilePicture.InputStream))
                        {
                            modelStudent.Photo = binaryReader.ReadBytes(modelStudent.FilePicture.ContentLength);
                        }
                    }
                    var myStudent = _studentRepository.GetById(modelStudent.Id);
                    Mapper.Map(modelStudent, myStudent);
                    _studentRepository.Update(myStudent);
                    const string title   = "Estudiante Actualizado";
                    var          content = "El estudiante " + myStudent.FullName + " ha sido actualizado exitosamente.";
                    _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    ViewBag.Tutor1Id = new SelectList(_tutorRepository.Query(x => x).OrderBy(x => x.FullName), "Id", "FullName",
                                                      modelStudent.Tutor1);
                    var items = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
                    {
                        Text  = c.GetEnumDescription(),
                        Value = c.ToString("D")
                    }).ToList();

                    ViewBag.Genders = new List <SelectListItem>(items);
                    ViewBag.Years   = DateTimeController.GetYears();
                    ViewBag.Months  = DateTimeController.GetMonths();
                    ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
                    return(View(modelStudent));
                }
            }
            ViewBag.Tutor1Id = new SelectList(_tutorRepository.Query(x => x).OrderBy(x => x.FullName), "Id", "FullName",
                                              modelStudent.Tutor1);
            var items2 = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
            {
                Text  = c.GetEnumDescription(),
                Value = c.ToString("D")
            }).ToList();

            ViewBag.Genders = new List <SelectListItem>(items2);
            ViewBag.Years   = DateTimeController.GetYears();
            ViewBag.Months  = DateTimeController.GetMonths();
            ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View(modelStudent));
        }
Ejemplo n.º 9
0
        public ActionResult Edit(AdministrativeEditModel modelAdmin)
        {
            var validImageTypes = new []
            {
                "image/gif",
                "image/jpeg",
                "image/pjpeg",
                "image/png"
            };

            if (modelAdmin.UploadPhoto != null && modelAdmin.UploadPhoto.ContentLength > 0)
            {
                if (!validImageTypes.Contains(modelAdmin.UploadPhoto.ContentType))
                {
                    ModelState.AddModelError("UploadPhoto", "Por favor seleccione entre una imagen GIF, JPG o PNG");
                }
            }
            if (ModelState.IsValid)
            {
                if (
                    _peopleWithUserRepository.Filter(x => x.IdNumber.Equals(modelAdmin.IdNumber) && x.Id != modelAdmin.Id && !x.User.Role.Name.Equals("Tutor"))
                    .Any())
                {
                    const string title   = "Error!";
                    const string content = "Ya existe un docente o administrativo con ese número de identidad.";
                    _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
                    return(RedirectToAction("Index"));
                }
                try
                {
                    if (modelAdmin.UploadPhoto != null)
                    {
                        using (var binaryReader = new BinaryReader(modelAdmin.UploadPhoto.InputStream))
                        {
                            modelAdmin.Photo = binaryReader.ReadBytes(modelAdmin.UploadPhoto.ContentLength);
                        }
                    }
                    var myAdmin = _peopleWithUserRepository.GetById(modelAdmin.Id);
                    Mapper.Map(modelAdmin, myAdmin);
                    _peopleWithUserRepository.Update(myAdmin);
                    const string title   = "Administrativo Actualizado";
                    var          content = "El administrativo " + myAdmin.FullName + " ha sido actualizado exitosamente.";
                    _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    var items = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
                    {
                        Text  = c.GetEnumDescription(),
                        Value = c.ToString("D")
                    }).ToList();

                    ViewBag.Genders = new List <SelectListItem>(items);
                    ViewBag.Years   = DateTimeController.GetYears();
                    ViewBag.Months  = DateTimeController.GetMonths();
                    ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
                    return(View(modelAdmin));
                }
            }
            var items2 = ((Gender[])Enum.GetValues(typeof(Gender))).Select(c => new SelectListItem
            {
                Text  = c.GetEnumDescription(),
                Value = c.ToString("D")
            }).ToList();

            ViewBag.Genders = new List <SelectListItem>(items2);
            ViewBag.Years   = DateTimeController.GetYears();
            ViewBag.Months  = DateTimeController.GetMonths();
            ViewBag.Days    = DateTimeController.GetDaysForMonthAndYearStatic(1, DateTime.UtcNow.Year);
            return(View(modelAdmin));
        }