예제 #1
0
        // GET: Admin/Grades/Edit
        public async Task <ActionResult> Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            GradeFormViewModel viewModel = null;

            try
            {
                var grade = await _gradeRepository.GetGradeById(id.Value);

                viewModel = new GradeFormViewModel(grade)
                {
                    IsNew = false
                };
            }
            catch (BadRequestException bre)
            {
                AddErrorsFromAdycHttpExceptionToModelState(bre, ModelState);
            }

            // Add properties to layout
            AddPageHeader(viewModel.Title, "");

            AddBreadcrumb("Grades", Url.Action("Index", "Grades", new { area = "Admin" }));
            AddBreadcrumb(viewModel.Title, "");

            return(View("GradeForm", viewModel));
        }