// POST api/student public HttpResponseMessage Post(Student student) { StudentRepository.InsertStudent(student); var response = Request.CreateResponse(HttpStatusCode.Created, student); string url = Url.Link("DefaultApi", new {student.Id}); response.Headers.Location = new Uri(url); return response; }
/// <summary> /// Inserts the student to database. /// </summary> /// <param name="student">The student object to insert.</param> public static void InsertStudent(Student student) { StudentDb.Students.Add(student); StudentDb.SaveChanges(); }