private void ModifyOrderState_Core(UserOrderPlvmWp userOrderPlvmWp, string confirmMsg, string successMsg, string errorMsg, Action <int, Action, Action <WebException> > modifyOrderAction, Action refreshViewAfterSuccess) { var messageBoxResult = MessageBox.Show(confirmMsg, "Megerősítés", MessageBoxButton.OKCancel); if (messageBoxResult == MessageBoxResult.Cancel) { return; } Action todoAfterResponseReceived = () => Dispatcher.BeginInvoke( () => { new ToastPrompt() { Message = successMsg }.Show(); refreshViewAfterSuccess(); }); Action <WebException> todoWithWebException = webException => Dispatcher.BeginInvoke( () => { MessageBox.Show(errorMsg); bool noUnderline; }); modifyOrderAction(userOrderPlvmWp.UserOrder.ID, todoAfterResponseReceived, todoWithWebException); }
private void ProductRemovedFromCartHandler(InBookBlockPvmByTransaction bookBlock) { // -- Remove the from-cart-removed book from the correspondent Cart UserOrderPlvmWp cartRemovedFrom = null; var wasAroundEnd = false; foreach (var userOrderPlvmWp in Carts) { var indexOfRemoved = userOrderPlvmWp.Products.IndexOf(bookBlock); if (indexOfRemoved >= 0) { cartRemovedFrom = userOrderPlvmWp; wasAroundEnd = (userOrderPlvmWp.Products.Count - indexOfRemoved) <= 3; // index is zero based userOrderPlvmWp.Products.RemoveAt(indexOfRemoved); break; } } // If we could not remove the item, something went wrong if (cartRemovedFrom == null) { throw new Exception(); } // If the removed item was one of the last 2 books in the last cart, because of a Framework bug, // the screen will be empty. The reason is only, we got out from the visible area, // so we have to scroll up a bit var isBigEnough = cartRemovedFrom.Products.Count >= 3; // the item is already removed var isLastCart = Carts[Carts.Count - 1] == cartRemovedFrom; if (wasAroundEnd && isLastCart && isBigEnough) { LongListSelectorCarts.ScrollTo(cartRemovedFrom); } // If the cart became empty if (cartRemovedFrom.Products.Count == 0) { Carts.Remove(cartRemovedFrom); } }