/// <summary> /// Delete a wine /// </summary> /// <param name="wine"></param> public void DeleteWine(Wine wine) { var wineToDelete = GetWineById(wine.Id); if (wineToDelete != null) { base.EbalitDBContext.Wines.Remove(wineToDelete); base.EbalitDBContext.SaveChanges(); } }
/// <summary> /// Update a wine /// </summary> /// <param name="wine"></param> public void UpdateWine(Wine wine) { var wineToUpdate = GetWineById(wine.Id); if (wineToUpdate != null) { base.EbalitDBContext.Entry(wineToUpdate).CurrentValues.SetValues(wine); base.EbalitDBContext.SaveChanges(); } }
/// <summary> /// Insert a new wine /// </summary> /// <param name="wine">the wine</param> /// <returns></returns> public int CreateWine(Wine wine) { base.EbalitDBContext.Wines.Add(wine); base.EbalitDBContext.SaveChanges(); return wine.Id; }