// POST api/hospitalizationsweb // POST api/Default2 public HttpResponseMessage Post(Hospitalization hospitalization) { string hosp = Request.Content.ReadAsStringAsync().Result; //Request.Content. Hospitalization result = Newtonsoft.Json.JsonConvert.DeserializeObject<Hospitalization>(hosp); if (ModelState.IsValid) { //db.Medics.Add(hospitalization); //db.SaveChanges(); hospitalizationsService.Add(hospitalization); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, hospitalization); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = hospitalization.hospitalizationID })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public Hospitalization Add(Hospitalization hospitalization) { context.HospitalizationRepository.Insert(hospitalization); context.Save(); return hospitalization; }