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; }
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; }