public void Post([FromBody] Ozzone value) { //var g = MongoDB.Bson.ObjectId.GenerateNewId().ToString(); //_ozonesRepository.Add(new Ozzone() { _id = g, DateTimeStart = DateTime.Now, Ozzone = value, Unit = "ppb" }); _ozonesRepository.Add(value); }
public async Task Add(Ozzone ozzoneEntry) { try { await _context.Ozones.InsertOneAsync(ozzoneEntry); } catch (Exception e) { throw new Exception("Error during adding Ozzone using MongoDB\n" + e.Message); } }
public async Task <UpdateResult> Update(Ozzone ozzoneEntry) { //in reality this is the closest case study I would imagine: //filter by the time it was taken var filter = Builders <Ozzone> .Filter.Eq(x => x.DateTimeStart, ozzoneEntry.DateTimeStart); //update or correct measurements var update = Builders <Ozzone> .Update.Set(x => x.Ozone, ozzoneEntry.Ozone); try { return(await _context.Ozones.UpdateOneAsync(filter, update)); } catch (Exception e) { throw new Exception("Error during updating Ozzone using MongoDB\n" + e.Message); } }
public void Put([FromBody] Ozzone value) { _ozonesRepository.Update(value); }