public IHttpActionResult PutCountryLocation(int id, CountryLocations countryLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != countryLocation.Id) { return(BadRequest()); } db.Entry(countryLocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CountryLocationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public CountryLocations Get(Int64 ixCountryLocation) { CountryLocations countrylocations = _context.CountryLocations.AsNoTracking().Where(x => x.ixCountryLocation == ixCountryLocation).First(); countrylocations.CountrySubDivisions = _context.CountrySubDivisions.Find(countrylocations.ixCountrySubDivision); return(countrylocations); }
public IHttpActionResult PostCountryLocation(CountryLocations countryLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CountryLocations.Add(countryLocation); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = countryLocation.Id }, countryLocation)); }
public IHttpActionResult DeleteCountryLocation(int id) { CountryLocations countryLocation = db.CountryLocations.Find(id); if (countryLocation == null) { return(NotFound()); } db.CountryLocations.Remove(countryLocation); db.SaveChanges(); return(Ok(countryLocation)); }