Ejemplo n.º 1
0
        // GET: Admin/CourseTypes/Edit
        public async Task <ActionResult> Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            CourseTypeFormViewModel viewModel = null;

            try
            {
                var courseType = await _courseTypeRepository.GetCourseTypeById(id.Value);

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

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

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

            return(View("CourseTypeForm", viewModel));
        }
        public IActionResult GetSingleCourseType(int id)
        {
            var singleCourseType = _repo.GetCourseTypeById(id);

            if (singleCourseType == null)
            {
                return(NotFound("This course type was not found in the database."));
            }

            return(Ok(singleCourseType));
        }