コード例 #1
0
        public void AddToWishList(Game game)
        {
            var wishListItem = storeDB.WishLists.SingleOrDefault(
                w => w.WishListId == WishListId &&
                     w.GameId == game.GameId);

            if (wishListItem == null)
            {
                // create a new wishlist item if none exists
                wishListItem = new WishList()
                {
                    GameId = game.GameId,
                    WishListId = WishListId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };

                storeDB.WishLists.Add(wishListItem);
            }
            else
            {
                // If the item does exist in the wishlist, then add one to the quantity
                wishListItem.Count++;
            }

            storeDB.SaveChanges();
        }
コード例 #2
0
 public WishListViewModel()
 {
     Friends = new List<Friends>();
     WishList = new WishList();
 }