public HttpResponseMessage Post(SchoolDto value) { var newSchool = new School { Location = value.Location, Name = value.Name }; HttpResponseMessage response; try { apiControllerHelper.Post<School>(newSchool); var createdSchoolDto = new SchoolDto() { Id = newSchool.Id, Name = newSchool.Name, Location = newSchool.Location }; response = Request.CreateResponse<SchoolDto>(HttpStatusCode.Created, createdSchoolDto); var resourceLink = Url.Link("DefaultApi", new { id = createdSchoolDto.Id }); response.Headers.Location = new Uri(resourceLink); } catch (Exception ex) { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex); } return response; }
public void TestInit() { scope = new TransactionScope(); var school = new School() { Name = "Sofia Maths High School", Location = "Sofia" }; repository.Create(school); schoolId = school.Id; }