public IHttpActionResult PutBlockedCountry(int id, BlockedCountry blockedCountry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != blockedCountry.BlockedCountryId) { return(BadRequest()); } db.Entry(blockedCountry).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BlockedCountryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetBlockedCountry(int id) { BlockedCountry blockedCountry = db.BlockedCountries.Find(id); if (blockedCountry == null) { return(NotFound()); } return(Ok(blockedCountry)); }
public IHttpActionResult PostBlockedCountry(BlockedCountry blockedCountry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BlockedCountries.Add(blockedCountry); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = blockedCountry.BlockedCountryId }, blockedCountry)); }
public IHttpActionResult DeleteBlockedCountry(int id) { BlockedCountry blockedCountry = db.BlockedCountries.Find(id); if (blockedCountry == null) { return(NotFound()); } db.BlockedCountries.Remove(blockedCountry); db.SaveChanges(); return(Ok(blockedCountry)); }