コード例 #1
0
        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
            };
        }
コード例 #2
0
 public async Task<IHttpActionResult> Post(CourseCreateModel create)
 {
     var result = await _commands.AddCourse(create);
     return CreatedAtRoute("GetCourse", new { id = result.Id }, result);
 }
コード例 #3
0
 public void SetCredentials()
 {
     SetupAuth("Alice", "alice");
     _model = new CourseCreateModel()
     {
         Title = "Sample",
         Description = "Description of Sample",
         NumberOfDays = 3
     };
 }