/// <summary> /// Navigate to Details page for a Unit Offering /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Details(int id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.UnitOffering)) { return(RedirectToPermissionDenied()); } if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { var unitOfferingModel = UnitOfferingProcessor.SelectUnitOfferingForUnitOfferingId(id); if (unitOfferingModel == null) { return(RedirectToIndexIdNotFound(id)); } var unit = UnitProcessor.SelectUnitForUnitId(unitOfferingModel.UnitId); var teachingPeriod = TeachingPeriodProcessor.SelectTeachingPeriodForTeachingPeriodId(unitOfferingModel.TeachingPeriodId); var year = YearProcessor.SelectYearForYearId(unitOfferingModel.YearId); var convenor = UserProcessor.SelectUserForUserId(unitOfferingModel.ConvenorId); var projectOfferings = ProjectOfferingProcessor.SelectProjectOfferingsForUnitOfferingId(id); var enrollments = EnrollmentProcessor.LoadEnrollmentsForUnitOffering(id); // Convert the model data to non-model data // Pass the data to the view var unitOffering = new UnitOffering(unitOfferingModel, unit, teachingPeriod, year, convenor, projectOfferings, enrollments); ViewBag.UserId = new SelectList(unitOffering.GetStudents( ), "UserId", "Username", null); return(View(unitOffering)); } catch (Exception e) { return(RedirectToIndex(e)); } // Find Unit Offering //db.GetUnitOffering( id ); // Populate Student Drop Down List for to add new Enrollments //PopulateStudentDropDownList( ); // Navigate to View //return View( db ); }
public Unit GetUnit(int id) { var data = UnitProcessor.SelectUnitForUnitId(id); var unit = new Unit { UnitId = data.UnitId, Name = data.Name }; Unit = unit; return(Unit); }
private void GetUnitOffering(int id) { var data = UnitOfferingProcessor.SelectUnitOfferingForUnitOfferingId(id); UnitOffering = new UnitOffering( ) { UnitOfferingId = data.UnitOfferingId, TeachingPeriodId = data.TeachingPeriodId, YearId = data.YearId, ConvenorId = data.ConvenorId, UnitId = data.UnitId, }; var teachingperiodData = TeachingPeriodProcessor.SelectTeachingPeriodForTeachingPeriodId(UnitOffering.TeachingPeriodId); UnitOffering.TeachingPeriod = new TeachingPeriod( ) { TeachingPeriodId = teachingperiodData.TeachingPeriodId, Name = teachingperiodData.Name, Day = teachingperiodData.Day, Month = teachingperiodData.Month }; var yearData = YearProcessor.SelectYearForYearId(UnitOffering.YearId); UnitOffering.Year = new Year( ) { YearId = yearData.YearId, YearValue = yearData.Year }; var convenorData = UserProcessor.SelectUserForUserId(UnitOffering.ConvenorId); UnitOffering.Convenor = new User( ) { UserId = convenorData.UserId, Username = convenorData.Username }; var unitData = UnitProcessor.SelectUnitForUnitId(UnitOffering.UnitId); UnitOffering.Unit = new Unit( ) { UnitId = unitData.UnitId, Name = unitData.Name }; }