public IHttpActionResult PutCountryWithPeople(int id, CountryWithPeople countryWithPeople) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != countryWithPeople.Id) { return(BadRequest()); } db.Entry(countryWithPeople).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CountryWithPeopleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCountryWithPeople(int id) { CountryWithPeople countryWithPeople = db.CountryWithPeoples.Find(id); if (countryWithPeople == null) { return(NotFound()); } return(Ok(countryWithPeople)); }
public IHttpActionResult PostCountryWithPeople(CountryWithPeople countryWithPeople) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CountryWithPeoples.Add(countryWithPeople); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = countryWithPeople.Id }, countryWithPeople)); }
public IHttpActionResult DeleteCountryWithPeople(int id) { CountryWithPeople countryWithPeople = db.CountryWithPeoples.Find(id); if (countryWithPeople == null) { return(NotFound()); } db.CountryWithPeoples.Remove(countryWithPeople); db.SaveChanges(); return(Ok(countryWithPeople)); }