public SchoolDTO CreateSchool(School school) { db.Schools.Add(school); db.SaveChanges(); return ToSchoolDTO(school); }
public SchoolDTO CreateSchool(School school) { return provider.CreateSchool(school); }
private SchoolDTO ToSchoolDTO(School s) { if (s == null) return null; return new SchoolDTO(s.id, s.title); }
public HttpResponseMessage PostSchool(School school) { if (ModelState.IsValid) { using (provider = new EntDAL.EFProvider()) { SchoolService service = new SchoolService(provider); SchoolDTO schoolDTO = service.CreateSchool(school); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, schoolDTO); return response; } } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }