public void DeleteInvestmentList(InvestmentWatchlistModel watchlist) { using (var context = _contextProvider.GetContext()) { var watchlistToDelete = context.InvestmentWatchlists.Single(wl => wl.Id == watchlist.Id); context.InvestmentWatchlists.Remove(watchlistToDelete); context.Save(); } Watchlists.Remove(watchlist); if (Watchlists.Any()) { SelectedWatchlist = Watchlists.Last(); } }
public void AddInvestmentList() { InvestmentWatchlistModel newWatchlist = new InvestmentWatchlistModel { Name = InvestmentListName, Description = InvestmentListDescription }; using (var context = _contextProvider.GetContext()) { context.InvestmentWatchlists.Add(newWatchlist); context.Save(); newWatchlist.Id = context.InvestmentWatchlists.ToList().Last().Id; } Watchlists.Add(newWatchlist); }