public void CreateOrder(string customerName, MerchandiseModel merchandise, int orderedAmount, bool isPending = false) { this.CustomerName = customerName; this.Merch = merchandise; this.OrderedAmount = orderedAmount; this.IsPendingOrder = isPending; }
public static MerchandiseDto ToDto(this MerchandiseModel merchandiseModel) { return(new MerchandiseDto ( merchandiseModel.Id, merchandiseModel.Name, merchandiseModel.Description, merchandiseModel.Type, merchandiseModel.Unit.ToString(), merchandiseModel.NettoPrice, merchandiseModel.Vat )); }
public static Merchandise FromCommModel(this MerchandiseModel merchandiseModel) { Enum.TryParse(merchandiseModel.Type, out ArticleType type); Enum.TryParse(merchandiseModel.Unit, out ArticleUnit unit); return(new Merchandise ( merchandiseModel.Id, merchandiseModel.Name, merchandiseModel.Description, type, unit, merchandiseModel.NettoPrice, merchandiseModel.Vat )); }
private void UpdateAmountDropDown(MerchandiseModel merch) { ClearAmountDropDown(); if (merch.Amount > 0) { for (int i = 0; i < merch.Amount; i++) { AmountDropDown.Items.Add(i + 1); } AmountDropDown.SelectedIndex = 0; } else // If there is no stock we can reset merch combo as well { localMerchandise.Clear(); PopulateAvailableMerchandise(); ConfirmOrderButton.IsEnabled = false; } }
private void PendingOrdersList_Loaded(object sender, RoutedEventArgs e) { var parent = (sender as Button).Parent; Grid grid = (Grid)parent; OrderModel tmpPendingOrder = grid.DataContext as OrderModel; if (tmpPendingOrder != null) { try { MerchandiseModel tmpMerch = vm.ObsMerch.First(x => x.ProductName == tmpPendingOrder.Merch.ProductName); if (tmpMerch.Amount >= tmpPendingOrder.OrderedAmount) { (sender as Button).IsEnabled = true; } } catch (Exception) { Debug.WriteLine("Cant find a pending merchandise in our merchandise list"); } } }
private async void ConfirmOrderButton_Click(object sender, RoutedEventArgs e) //lägg till skriva till fil (i båda satser) { ConfirmOrderButton.IsEnabled = false; OrderModel newOrder = new OrderModel(); OrderModel pendingOrder = new OrderModel(); CustomerModel tmpCustModel = CustomerCombo.SelectedItem as CustomerModel; MerchandiseModel tmpMerchModel = GetMerchModel(MerchCombo); int orderedAmount; if (isOrderPending) { orderedAmount = Int32.Parse(AmountTextBox.Text); pendingOrder.CreateOrder(tmpCustModel.Name, tmpMerchModel, orderedAmount, true); vm.PendingOrder.Insert(0, pendingOrder); ResetAddOrderButton(); ClearAmountTextBox(); } else { orderedAmount = Int32.Parse(AmountDropDown.SelectedItem.ToString()); tmpMerchModel.RemoveStock(orderedAmount); newOrder.CreateOrder(tmpCustModel.Name, tmpMerchModel, orderedAmount); vm.Order.Insert(0, newOrder); await Task.Delay(500); await FileManager.SaveToFile(vm.ObsMerch); UpdateAmountDropDown(tmpMerchModel); ResetOrderHistoryItemsSource(); } }
private async void MerchCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { MerchandiseModel tmpMerchModel = GetMerchModel(sender); ClearAmountDropDown(); if (tmpMerchModel != null) { for (int i = 0; i < tmpMerchModel.Amount; i++) { AmountDropDown.Items.Add(i + 1); } } AmountDropDown.Visibility = Visibility.Visible; AmountDropDown.IsEnabled = true; AmountTextBox.Visibility = Visibility.Collapsed; ClearAmountTextBox(); var message = "Product has been added to order"; MessageDialog messageDialog = new MessageDialog(message); if (tmpMerchModel != null && tmpMerchModel.Amount <= 0) { message = "This product is not currently in stock! If you proceed with the order, it will be added to the pending order queue."; messageDialog = new MessageDialog(message, "Warning!"); await messageDialog.ShowAsync(); AmountDropDown.IsEnabled = false; AmountDropDown.Visibility = Visibility.Collapsed; AmountTextBox.Visibility = Visibility.Visible; } // Always reset button when we change merchandise ResetAddOrderButton(); }