public void AddToObserver(int bookId) { var observer = GetObserver(); var observerPosition = observer.Find(b => b.Book.BookId == bookId); if (observerPosition != null) { observerPosition.Amount = observerPosition.Amount; } else { var bookToAdd = db.Books.Where(b => b.BookId == bookId).SingleOrDefault(); if (bookToAdd != null) { var newObserverPosition = new ObservePosition() { Book = bookToAdd, Amount = 1, }; observer.Add(newObserverPosition); } } session.Set(Consts.ObserverSessionKey, observer); }
public void AddToObserver(int gameId) { var observer = GetObserver(); var observerPosition = observer.Find(g => g.Game.GameId == gameId); if (observerPosition != null) { observerPosition.Amount = observerPosition.Amount; } else { var gameToAdd = context.Games.Where(b => b.GameId == gameId).SingleOrDefault(); if (gameToAdd != null) { var newObserverPosition = new ObservePosition() { Game = gameToAdd, Amount = 1, }; observer.Add(newObserverPosition); } } session.Set(ConfigurationManager.AppSettings["ObserverSessionKey"], observer); }