public HttpResponseMessage Post(SchoolModel school) { var responseMsg = this.PerformOperationAndHandleExceptions(() => { var newcSchool = new School() { Location = school.Location, Name = school.Name }; var db = new SchoolContext(); db.Schools.Add(newcSchool); db.SaveChanges(); school.Id = newcSchool.Id; var response = this.Request.CreateResponse(HttpStatusCode.Created, school); return response; }); return responseMsg; }
public HttpResponseMessage Post(StudentModel student) { var responseMsg = this.PerformOperationAndHandleExceptions(() => { var newStudent = new Student() { FirstName = student.FirstName, LastName = student.LastName, Age = student.Age, Grade = student.Grade, School = null, SchoolId = null }; var db = new SchoolContext(); db.Students.Add(newStudent); db.SaveChanges(); student.Id = newStudent.Id; var response = this.Request.CreateResponse(HttpStatusCode.Created, student); return response; }); return responseMsg; }