public async Task<CourseSummaryModel> AddCourse(CourseCreateModel course) { var courseToAdd = new Course(); courseToAdd.Title = course.Title; courseToAdd.Description = course.Description; courseToAdd.NumberOfDays = course.NumberOfDays; courseToAdd.Active = true; _context.Courses.Add(courseToAdd); await _context.SaveChangesAsync(); return new CourseSummaryModel() { Id = courseToAdd.Id, Title = courseToAdd.Title, Description = courseToAdd.Description, NumberOfDays = courseToAdd.NumberOfDays }; }
public async Task<IHttpActionResult> Post(CourseCreateModel create) { var result = await _commands.AddCourse(create); return CreatedAtRoute("GetCourse", new { id = result.Id }, result); }
public void SetCredentials() { SetupAuth("Alice", "alice"); _model = new CourseCreateModel() { Title = "Sample", Description = "Description of Sample", NumberOfDays = 3 }; }