Example #1
0
        public IActionResult Post([FromBody] Course course)
        {
            if (ModelState.IsValid)
            {
                int newId = _courseRepo.Add(course);
                if (newId >= 0)
                {
                    course.Id = newId;
                    return(new CreatedResult("/course/post", course));
                }
                else
                {
                    return(new NotFoundResult());
                }
            }

            return(BadRequest("Invalid Course Model"));
        }
Example #2
0
 public async Task AddAndSave(Course course)
 {
     _repo.Add(course);
     await _repo.Save();
 }