public async void AddBasket(long ProductID, decimal Amount) { InterfaceToDataBaseBasketMethods Methods = new InterfaceToDataBaseBasketMethods(); if (!(await(Methods.MoveProductToBasket(loggedUserData.UserID, ProductID, Amount)))) { throw new ArgumentException(); } basketSizeLabel.Text = Methods.CountBaskets(loggedUserData.UserID).Result.ToString(); }
//public async void ModifyBasket(Basket basketDataObject, decimal newAmount, Product modifiedProduct = null) //{ // InterfaceToDataBaseProductMethods Methods = new InterfaceToDataBaseProductMethods(); // if (modifiedProduct == null) // modifiedProduct = await Methods.GetProductData(basketDataObject.ProductID); // await Methods.ProductModification(basketDataObject.ProductID, null, null, null, null, modifiedProduct.Amount + basketDataObject.Amount - newAmount); // //int index = loggedUserBasket.FindIndex(x => x.BasketID == basketDataObject.BasketID); // //loggedUserBasket[index].Amount = newAmount; // //loggedUserBasket[index].Date = DateTime.Now; // InterfaceToDataBaseBasketMethods BasketMethods = new InterfaceToDataBaseBasketMethods(); // await BasketMethods.ModifyBasket(basketDataObject.BasketID, newAmount); // ForceBasketRefresh(); //} public async void MoveProductsToFromBasket(long ProductID, decimal Amount) { InterfaceToDataBaseBasketMethods BasketMethods = new InterfaceToDataBaseBasketMethods(); bool result = false; if (Amount < 0) { result = await BasketMethods.MoveProductFromBasket(loggedUserData.UserID, ProductID, -Amount); } else if (Amount > 0) { result = await BasketMethods.MoveProductToBasket(loggedUserData.UserID, ProductID, Amount); } if (!result) { throw new ArgumentException(); } ForceBasketRefresh(); }