示例#1
0
        public async Task <IActionResult> Create(
            [FromBody] CourseRegistration registration)
        {
            if (registration == null)
            {
                return(BadRequest("Course registration not given"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("The given course registration is invalid"));
            }

            var result = await _courseCreator.Create(registration);

            if (result.Successful())
            {
                return(Ok(result.Body()));
            }
            return(BadRequest(result.GetAggregatedErrors()));
        }
示例#2
0
        public ActionResult AddCourse(CourseViewModel course)
        {
            _courseCreator.Create(course.Name, course.DepartmentId);

            return(RedirectToAction("Index"));
        }