public ActionResult Courses() { var courseDal = new Course_DAL(); var courses = courseDal.InstanceOfCourses(User.Identity.GetUserId()); return(View(courses)); }
public ActionResult Program() { var courseDal = new Course_DAL(); var courses = courseDal.InstanceOfCourses(); ViewBag.courses = courses.Select(i => new SelectListItem() { Text = $"Curso:{i.CourseName}, Profesor:{i.teacherName}, Programación: {i.Date.ToShortDateString()} desde las {i.StartTime} hasta las {i.FinalTime}", Value = i.InstanceOfCourseID.ToString() }); return(View(new InscriptionStudentViewModel() { InstanceOfCourse = new InstanceOfCourseViewModel() })); }
public ActionResult Program(InscriptionStudentViewModel model) { var courseDal = new Course_DAL(); if (ModelState.IsValid) { var newModel = new T_InscriptionStudent { InscriptionStudentID = Guid.NewGuid(), Assistance = false, Observation = string.Empty, StudentID = User.Identity.GetUserId(), InstanceOfCourseID = model.InstanceOfCourse.InstanceOfCourseID, CreateDate = DateTime.Now, ModificationDate = DateTime.Now, LogicalErasure = false }; try { var response = courseDal.AddInscription(newModel); if (response != null) { return(RedirectToAction("ProgramList")); } } catch (Exception ex) { ModelState.AddModelError("", "Operacion no valida, recuerde que solo puede agregar hasta 4 materias"); ModelState.AddModelError("", "Operacion no valida, No se puede agreagar materias repetidas"); ModelState.AddModelError("", ex.Message); } } var courses = courseDal.InstanceOfCourses(); ViewBag.courses = courses.Select(i => new SelectListItem() { Text = $"{i.CourseName}-{i.teacherName} {i.Date}-{i.StartTime}/{i.FinalTime}", Value = i.InstanceOfCourseID.ToString() }); return(View(model)); }