public CellarEntry InsertEntry(CellarEntry entry) { var db = GetDatabase(); var result = db.GetCollection <CellarEntry>(BeerCellarDatabase.Collections.MyBeers).Insert <CellarEntry>(entry); // For now... I'll return the entry later return(null); }
public CellarEntry UpdateEntry(CellarEntry entry) { var db = GetDatabase(); // I should be doing this by id var q = Query.And(Query <CellarEntry> .EQ(e => e.BeerName, entry.BeerName), Query <CellarEntry> .EQ(e => e.BreweryName, entry.BreweryName)); var myBeers = db.GetCollection <CellarEntry>(BeerCellarDatabase.Collections.MyBeers); myBeers.Update(q, update: Update <CellarEntry> .Set(e => e.Count, BsonValue.Create(entry.Count))); return(entry); }
/// <summary> /// PUT api/beercellar/5 /// updates the entry with the given id /// </summary> /// <param name="id"></param> /// <param name="value"></param> public void Put([FromBody] CellarEntry entry) { var repo = BeerCellarRespositoryProvider.GetRepository(); repo.UpdateEntry(entry); }
/// <summary> /// POST api/beercellar /// Inserts the given entry /// </summary> /// <param name="value">the json representation of a CellarEntry</param> public void Post([FromBody] CellarEntry entry) { var repo = BeerCellarRespositoryProvider.GetRepository(); repo.InsertEntry(entry); }