// Add new item public Course AddCourse(CourseAdd Course) { // Map from DTO object to domain (POCO) object var p = ds.Courses.Add(Mapper.Map<ICTGWS.Models.Course>(Course)); ds.SaveChanges(); // Map to DTO object return Mapper.Map<Course>(p); }
public HttpResponseMessage PostCourse(CourseAdd course) { if (ModelState.IsValid) { // Add the new item var c = r.AddCourse(course); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, course); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = course.CourseId })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }