コード例 #1
0
        public static bool Update(WishListModel wishListModel)
        {
            Wishlist original = DatabaseManager.Instance.Wishlist.Find(wishListModel.Id);

            if (original != null)
            {
                DatabaseManager.Instance.Entry(original).CurrentValues.SetValues(ToDbModel(wishListModel));
                DatabaseManager.Instance.SaveChanges();
                return(true);
            }
            return(false);
        }
コード例 #2
0
        private static Wishlist ToDbModel(WishListModel wishListModel)
        {
            Wishlist wishListDb = new()
            {
                WishListBrand       = wishListModel.Brand,
                WishListCreatedDate = wishListModel.CreatedDate,
                WishListDescription = wishListModel.Description,
                WishListId          = wishListModel.Id,
                WishListInStock     = wishListModel.InStock,
                WishListNotes       = wishListModel.Notes,
                WishListPrice       = wishListModel.Price,
                WishListQty         = wishListModel.Qty,
                WishListSku         = wishListModel.Sku
            };

            return(wishListDb);
        }
    }
コード例 #3
0
        public static WishListModel Add(WishListModel wishListModel)
        {
            Wishlist wishListDb = ToDbModel(wishListModel);

            DatabaseManager.Instance.Wishlist.Add(wishListDb);
            DatabaseManager.Instance.SaveChanges();

            wishListModel = new WishListModel
            {
                Brand       = wishListDb.WishListBrand,
                CreatedDate = wishListDb.WishListCreatedDate,
                Description = wishListDb.WishListDescription,
                Id          = wishListDb.WishListId,
                InStock     = wishListDb.WishListInStock,
                Notes       = wishListDb.WishListNotes,
                Price       = wishListDb.WishListPrice,
                Qty         = wishListDb.WishListQty,
                Sku         = wishListDb.WishListSku
            };
            return(wishListModel);
        }