// Add new item public Student AddStudent(StudentAdd Student) { // Map from DTO object to domain (POCO) object var p = ds.Students.Add(Mapper.Map<ICTGWS.Models.Student>(Student)); //<=== ds.SaveChanges(); // Map to DTO object return Mapper.Map<Student>(p); }
public HttpResponseMessage PostStusent(StudentAdd student) { if (ModelState.IsValid) { // Add the new item var c = r.AddStudent(student); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, student); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = student.StId})); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }