Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }