public IHttpActionResult AddCourse(CourseDTO c) { //checking if the course being added is not of the right data type if (c == null) { throw new HttpResponseException(HttpStatusCode.PreconditionFailed); } //setting location url var location = Url.Link("GetCourse", new { id = c.ID }); //adding course to list //_courses.Add(c); return Created(location, c); }
public IHttpActionResult UpdateCourse(int id, CourseDTO course) { //checking if the course being added is not of the right data type if (course == null) { throw new HttpResponseException(HttpStatusCode.PreconditionFailed); } //update right course /* foreach (CourseDTO c in _courses) { if (c.ID == id) { var temp = _courses.SingleOrDefault(x=>x.ID == course.ID); temp.Name = course.Name; temp.StartDate = course.StartDate; temp.EndDate = course.EndDate; //201 successfully created var location = Url.Link("GetCourse", new { id = course.ID }); return Created(location, temp); } }*/ //404 id not found return NotFound(); }