Пример #1
0
        private void Add_OnClick(Wine wine)
        {
            if (IsWaiting)
            {
                return;
            }

            IsWaiting = true;

            if (wine.CheckoutQuantity < wine.Quantity)
            {
                int  selectedIndex = SelectedWines.Select((w, index) => new { w, index }).First(w => w.w.Id == wine.Id).index;
                Wine selectedWine  = SelectedWines[selectedIndex];
                ++selectedWine.CheckoutQuantity;
                SelectedWines.RemoveAt(selectedIndex);
                SelectedWines.Insert(selectedIndex, selectedWine);
            }
            else
            {
                MessagingService.Current.SendMessage <MessagingServiceAlert>(MessageKeys.Message,
                                                                             new MessagingServiceAlert
                {
                    Message = $"Quantity available to checkout is {wine.Quantity}",
                    Cancel  = "OK"
                });
            }

            IsWaiting = false;
        }
Пример #2
0
        private void Remove_OnClick(Wine wine)
        {
            if (IsWaiting)
            {
                return;
            }

            IsWaiting = true;

            if (wine.CheckoutQuantity != 0)
            {
                int  selectedIndex = SelectedWines.Select((w, index) => new { w, index }).First(w => w.w.Id == wine.Id).index;
                Wine tempWine      = SelectedWines[selectedIndex];
                --tempWine.CheckoutQuantity;
                SelectedWines.RemoveAt(selectedIndex);
                SelectedWines.Insert(selectedIndex, tempWine);
            }

            IsWaiting = false;
        }