public async Task <ActionResult <MongodbAmbient> > Post([FromBody] MongodbAmbient Ambient)
        {
            Ambient.Id = await _repo.GetNextId();

            await _repo.Create(Ambient);

            return(new OkObjectResult(Ambient));
        }
        public async Task <ActionResult <MongodbAmbient> > Put(long id, [FromBody] MongodbAmbient Ambient)
        {
            var AmbientFromDb = await _repo.GetAmbient(id); if (AmbientFromDb == null)

            {
                return(new NotFoundResult());
            }
            Ambient.Id = AmbientFromDb.Id;

            Ambient.InternalId = AmbientFromDb.InternalId; await _repo.Update(Ambient); return(new OkObjectResult(Ambient));
        }
示例#3
0
        public async Task <bool> Update(MongodbAmbient Ambient)
        {
            ReplaceOneResult updateResult =
                await _context
                .Ambients
                .ReplaceOneAsync(
                    filter : g => g.Id == Ambient.Id,
                    replacement : Ambient);

            return(updateResult.IsAcknowledged &&
                   updateResult.ModifiedCount > 0);
        }
示例#4
0
 public async Task Create(MongodbAmbient Ambient)
 {
     await _context.Ambients.InsertOneAsync(Ambient);
 }