public async Task <ActionResult <MongodbLocation> > Post([FromBody] MongodbLocation Location) { Location.Id = await _repo.GetNextId(); await _repo.Create(Location); return(new OkObjectResult(Location)); }
public async Task <ActionResult <MongodbLocation> > Put(long id, [FromBody] MongodbLocation Location) { var LocationFromDb = await _repo.GetLocation(id); if (LocationFromDb == null) { return(new NotFoundResult()); } Location.Id = LocationFromDb.Id; Location.InternalId = LocationFromDb.InternalId; await _repo.Update(Location); return(new OkObjectResult(Location)); }
public async Task <bool> Update(MongodbLocation Location) { ReplaceOneResult updateResult = await _context .Locations .ReplaceOneAsync( filter : g => g.Id == Location.Id, replacement : Location); return(updateResult.IsAcknowledged && updateResult.ModifiedCount > 0); }
public async Task Create(MongodbLocation Location) { await _context.Locations.InsertOneAsync(Location); }