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())); }
public ActionResult AddCourse(CourseViewModel course) { _courseCreator.Create(course.Name, course.DepartmentId); return(RedirectToAction("Index")); }