예제 #1
0
        public ActionResult Edit(int startYear)
        {
            AcademicYear academicYear = this.academicYearService.All()
                                        .FirstOrDefault(y => y.StartDate.Year == startYear);

            AcademicYearDetailsEditModel model = Mapper.Map <AcademicYear, AcademicYearDetailsEditModel>(academicYear);

            return(View(model));
        }
        public ActionResult Edit(AcademicYearDetailsEditModel academicYearDetailsModel)
        {
            var myAcademicYearDetails = _academicYearDetailsRepository.GetById(academicYearDetailsModel.Id);

            myAcademicYearDetails.TeacherStartDate = academicYearDetailsModel.TeacherStartDate.AsDateTime();
            myAcademicYearDetails.TeacherEndDate   = academicYearDetailsModel.TeacherEndDate.AsDateTime();
            myAcademicYearDetails.Schedule         = academicYearDetailsModel.Schedule.AsDateTime();
            myAcademicYearDetails.Room             = academicYearDetailsModel.Room;
            myAcademicYearDetails.Course           = _courseRepository.GetById(academicYearDetailsModel.Course.Id);
            myAcademicYearDetails.Teacher          = _teacherRepository.GetById(academicYearDetailsModel.Teacher.Id);
            _academicYearDetailsRepository.Update(myAcademicYearDetails);
            const string title   = "El Detalle del Año Académico Actualizado ";
            var          content = "El detalle " + myAcademicYearDetails.Course.Name + " ha sido actualizado exitosamente.";

            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.InformationMessage);
            return(Redirect(string.Format("~/AcademicYearDetails/Index/{0}", myAcademicYearDetails.AcademicYear.Id)));
        }
        public ActionResult Edit(int id)
        {
            var academicYearDetails = _academicYearDetailsRepository.GetById(id);
            var academicYearModel   = new AcademicYearDetailsEditModel
            {
                Id = academicYearDetails.Id,
                TeacherStartDate = academicYearDetails.TeacherStartDate.ToString(),
                TeacherEndDate   = academicYearDetails.TeacherEndDate.ToString(),
                Schedule         = academicYearDetails.Schedule.ToString(),
                Room             = academicYearDetails.Room,
                Course           = academicYearDetails.Course,
                Teacher          = academicYearDetails.Teacher
            };

            ViewBag.CourseId  = new SelectList(_courseRepository.Query(x => x), "Id", "Name", academicYearModel.Course.Id);
            ViewBag.TeacherId = new SelectList(_teacherRepository.Query(x => x), "Id", "FullName", academicYearModel.Teacher.Id);
            return(View("Edit", academicYearModel));
        }
예제 #4
0
        public ActionResult Edit(AcademicYearDetailsEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            AcademicYear academicYear = this.academicYearService.GetById(model.Id);

            if (academicYear == null)
            {
                ModelState.AddModelError(string.Empty, "Invalid or not existing year.");

                return(View(model));
            }

            Mapper.Map(model, academicYear);

            this.academicYearService.Update(academicYear);

            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(int id)
 {
     var academicYearDetails = _academicYearDetailsRepository.GetById(id);
     var academicYearModel = new AcademicYearDetailsEditModel
     {
         Id = academicYearDetails.Id,
         TeacherStartDate = academicYearDetails.TeacherStartDate.ToString(),
         TeacherEndDate = academicYearDetails.TeacherEndDate.ToString(),
         Schedule = academicYearDetails.Schedule.ToString(),
         Room = academicYearDetails.Room,
         Course = academicYearDetails.Course,
         Teacher = academicYearDetails.Teacher
     };
     ViewBag.CourseId = new SelectList(_courseRepository.Query(x => x), "Id", "Name", academicYearModel.Course.Id);
     ViewBag.TeacherId = new SelectList(_teacherRepository.Query(x => x), "Id", "FullName", academicYearModel.Teacher.Id);
     return View("Edit", academicYearModel);
 }
 public ActionResult Edit(AcademicYearDetailsEditModel academicYearDetailsModel)
 {
     var myAcademicYearDetails = _academicYearDetailsRepository.GetById(academicYearDetailsModel.Id);
     myAcademicYearDetails.TeacherStartDate = academicYearDetailsModel.TeacherStartDate.AsDateTime();
     myAcademicYearDetails.TeacherEndDate = academicYearDetailsModel.TeacherEndDate.AsDateTime();
     myAcademicYearDetails.Schedule = academicYearDetailsModel.Schedule.AsDateTime();
     myAcademicYearDetails.Room = academicYearDetailsModel.Room;
     myAcademicYearDetails.Course = _courseRepository.GetById(academicYearDetailsModel.Course.Id);
     myAcademicYearDetails.Teacher = _teacherRepository.GetById(academicYearDetailsModel.Teacher.Id);
     _academicYearDetailsRepository.Update(myAcademicYearDetails);
     const string title = "El Detalle del Año Académico Actualizado ";
     var content = "El detalle " + myAcademicYearDetails.Course.Name + " ha sido actualizado exitosamente.";
     _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.InformationMessage);
     return Redirect(string.Format("~/AcademicYearDetails/Index/{0}", myAcademicYearDetails.AcademicYear.Id));
 }