public async Task PutLocations(int id, [FromBody] LocationsEntry value) { try { var old = await _db.Locations.FindAsync(id); _db.Entry(old).CurrentValues.SetValues(value); await _db.SaveChangesAsync(); } catch (Exception error) { throw new Exception(error.Message); } }
public async Task <IActionResult> PostLocations([FromBody] LocationsEntry value) { if (ModelState.IsValid) { await _db.Locations.AddAsync(value); await _db.SaveChangesAsync(); return(Ok("Ok")); } else { return(new BadRequestObjectResult("Not Found")); } }