private void btnAddWine_Click(object sender, RoutedEventArgs e) { var winevm = pnlWineDataFields.DataContext as WineViewModel; if (winevm != null) { var wine = new Wine() { Id = Guid.NewGuid(), WineName = winevm.Name, Country = winevm.Country, Grape = winevm.Grape, Region = winevm.Region, Sortiment = winevm.Sortiment, Price = winevm.Price }; _db.WineSet.AddObject(wine); _db.SaveChanges(); } refreshWineList(); refreshValueStats(); refreshCountryStats(); pnlWineDataFields.DataContext = new WineViewModel(); }
/// <summary> /// Deprecated Method for adding a new object to the WineSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToWineSet(Wine wine) { base.AddObject("WineSet", wine); }
/// <summary> /// Create a new Wine object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="wineName">Initial value of the WineName property.</param> /// <param name="country">Initial value of the Country property.</param> /// <param name="grape">Initial value of the Grape property.</param> /// <param name="price">Initial value of the Price property.</param> public static Wine CreateWine(global::System.Guid id, global::System.String wineName, global::System.String country, global::System.String grape, global::System.Double price) { Wine wine = new Wine(); wine.Id = id; wine.WineName = wineName; wine.Country = country; wine.Grape = grape; wine.Price = price; return wine; }