예제 #1
0
 public SchoolDTO CreateSchool(School school)
 {
     db.Schools.Add(school);
     db.SaveChanges();
     return ToSchoolDTO(school);
 }
예제 #2
0
 public SchoolDTO CreateSchool(School school)
 {
     return provider.CreateSchool(school);
 }
예제 #3
0
        private SchoolDTO ToSchoolDTO(School s)
        {
            if (s == null) return null;

            return new SchoolDTO(s.id, s.title);
        }
예제 #4
0
        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);
            }
        }