public async Task <ActionResult> New(ShowOfferingFormViewModel form) { if (!form.TermId.HasValue) { return(HttpNotFound()); } var professors = await _professorRepository.GetNotTrashedProfessors(); var viewModel = new OfferingFormViewModel { IsNew = true, TermId = form.TermId.Value }; await SetOfferingListProperties(viewModel); // Add properties to layout AddPageHeader(viewModel.FormTitle, ""); AddBreadcrumb("Offerings (Terms)", Url.Action("Index")); AddBreadcrumb("Offerings (List)", Url.Action("View", new { TermId = form.TermId.Value })); AddBreadcrumb(viewModel.FormTitle, ""); return(View("OfferingForm", viewModel)); }
public async Task <ActionResult> Edit(ShowOfferingFormViewModel form) { if (!form.TermId.HasValue) { return(HttpNotFound()); } OfferingFormViewModel viewModel = null; try { var offering = await _offeringRepository.GetOfferingById(form.OfferingId.Value); viewModel = new OfferingFormViewModel(offering) { IsNew = false }; } catch (BadRequestException bre) { AddErrorsFromAdycHttpExceptionToModelState(bre, ModelState); } await SetOfferingListProperties(viewModel); // Add properties to layout AddPageHeader(viewModel.FormTitle, ""); AddBreadcrumb("Offerings (Terms)", Url.Action("Index")); AddBreadcrumb("Offerings (List)", Url.Action("View", new { TermId = form.TermId.Value })); AddBreadcrumb(viewModel.FormTitle, ""); return(View("OfferingForm", viewModel)); }
private async Task SetOfferingListProperties(OfferingFormViewModel viewModel) { viewModel.Courses = await _courseRepository.GetNotTrashedCourses(); viewModel.Professors = await _professorRepository.GetNotTrashedProfessors(); viewModel.Terms = await _termRepository.GetTerms(); }
public async Task <ActionResult> Save(OfferingFormViewModel form) { if (ModelState.IsValid) { try { OfferingDto offering = (form.IsNew) ? new OfferingDto() : await _offeringRepository.GetOfferingById(form.Id.Value); offering.Title = form.Title; offering.Location = form.Location; offering.OfferingDays = form.OfferingDays; offering.Notes = form.Notes; offering.ProfessorId = form.ProfessorId; offering.CourseId = form.CourseId; offering.TermId = form.TermId; if (form.IsNew) { await _offeringRepository.PostOffering(offering); } else { await _offeringRepository.PutOffering(offering.Id, offering); } AddPageAlerts(ViewHelpers.PageAlertType.Success, "Your changes have been saved succesfully."); return(RedirectToAction("View", new { termId = form.TermId })); } catch (BadRequestException bre) { AddErrorsFromAdycHttpExceptionToModelState(bre, ModelState); } } await SetOfferingListProperties(form); // Add properties to layout AddPageHeader(form.FormTitle, ""); AddBreadcrumb("Offerings (Terms)", Url.Action("Index")); AddBreadcrumb("Offerings (List)", Url.Action("View", new { TermId = form.TermId })); AddBreadcrumb(form.FormTitle, ""); return(View("OfferingForm", form)); }
public GivePage() { InitializeComponent(); BindingContext = vm = new OfferingFormViewModel(); vm.TransactionCommand.Execute(null); }
public LiveGivePage() { InitializeComponent(); BindingContext = vm = new OfferingFormViewModel(); }