private void ResetFields() { Quantity = 0; SelectedTable = Tables.FirstOrDefault(); SelectedOrderItem = OrderItems.FirstOrDefault(); TableDropdownEnabled = true; OrderItemsDropdownEnabled = true; IsEditMode = false; }
public OrderItem GetOrderItemById(long id) { var ois = OrderItems.FirstOrDefault(g => g.OrderItemId == id); if (ois == null) { throw new DomainArgumentNullException("Het gevraagde order item is niet gevonden"); } return(ois); }
private async void AddProduct(Product product) { this.decimalTextBox.Text = "1"; this.quantityDialog.Content = this.decimalTextBox; this.quantityDialog.Title = "Enter quantity"; ContentDialogResult result = await this.ShowQuantityDialog(); if (result == ContentDialogResult.Primary) { TextBox input = (TextBox)quantityDialog.Content; decimal.TryParse(input.Text, out decimal quantity); if (quantity == 0) { quantity = 1; } if (quantity <= product.Quantity) { if (OrderItems.Any(p => p.OrderItem.ProductId == product.ProductId)) { OrderItemListView existingItem = OrderItems.FirstOrDefault(p => p.OrderItem.ProductId == product.ProductId); int index = OrderItems.IndexOf(existingItem); existingItem.OrderItem.Quantity += quantity; OrderItemListView orderItemListView = this.GetDuplicatedItem(existingItem); OrderItems.RemoveAt(index); OrderItems.Insert(index, orderItemListView); } else { OrderItemListView orderItem = new OrderItemListView { OrderItem = new OrderItem { Product = product, ProductId = product.ProductId, Quantity = quantity, LineDiscount = 0, SubTotal = this.GetSubTotal(product.SellingPrice, quantity, 0) } }; orderItem.ItemDeleteClicked += this.HandleItemDeleted; OrderItems.Add(orderItem); } RaisePropertyChanged("OrderItems"); RaisePropertyChanged("IsProceedEnabled"); } else { this.messageDialog.Content = "Insufficient quantity !"; await this.messageDialog.ShowAsync(); } this.SearchText = product.Name; } this.SearchText = string.Empty; }
public void RemoveItem(Guid orderItemId) { var orderItem = OrderItems.FirstOrDefault(x => x.Id == orderItemId); if (orderItem == null) { AddNotification("Order", "This item doesn't exist in your list."); } _orderItems.Remove(orderItem); }
public void UpdateOrderItem(OrderItem orderItem) { if (!orderItem.IsValid()) { return; } orderItem.SetOrder(Id); var existentOrderItem = OrderItems.FirstOrDefault(p => p.ProductId == orderItem.ProductId); if (existentOrderItem == null) { throw new DomainException("Item doesn't belong the order"); } }
public void RemoveItem(OrderItem item) { if (!item.IsValid()) { return; } var itemInOrder = OrderItems.FirstOrDefault(p => p.CourseId == item.CourseId); if (itemInOrder == null) { throw new DomainException("O item não pertence ao order"); } _orderItems.Remove(itemInOrder); CalculateOrderValue(); }
public OrderItem AddOrderItem(OrderItem oi) { if (Submitted) { throw new NotSupportedException("It is not allowed to change a finalized order"); } if (OrderItems.FirstOrDefault(g => g.ProductId == oi.ProductId) != null) { OrderItems.FirstOrDefault(g => g.ProductId == oi.ProductId).Amount++; return(OrderItems.FirstOrDefault(g => g.ProductId == oi.ProductId)); } else { OrderItems.Add(oi); return(oi); } }
public OrderItem AddOrderItem(OrderItem oi) { if (Submitted) { Submitted = false; } if (OrderItems.FirstOrDefault(g => g.ProductId == oi.ProductId) != null) { OrderItems.FirstOrDefault(g => g.ProductId == oi.ProductId).Amount++; return(OrderItems.FirstOrDefault(g => g.ProductId == oi.ProductId)); } else { OrderItems.Add(oi); return(oi); } }
public void UpdateItem(OrderItem orderItem) { if (!orderItem.IsValid().IsValid) { return; } orderItem.AddOrder(Id); ExistingItemValidate(orderItem); ValidItemQtyAllowed(orderItem); var existingItem = OrderItems.FirstOrDefault(p => p.ProductId == orderItem.ProductId); _orderItems.Remove(existingItem); _orderItems.Add(orderItem); CalculateOrderAmount(); }
public void UpdateItem(OrderItem item) { if (!item.IsValid()) { return; } item.AssociateOrder(Id); var existingItem = OrderItems.FirstOrDefault(x => x.ProductId == item.ProductId); if (existingItem == null) { throw new DomainException("Unable to find Item on Order."); } _orderItems.Remove(existingItem); _orderItems.Add(item); CalculateTotalValue(); }
public void AddProduct(Guid productId, int count) { if (count <= 0) { throw new ArgumentException("You can not add zero or negative count of products!", nameof(count)); } var existingItems = OrderItems.FirstOrDefault(ol => ol.ProductId == productId); if (existingItems == null) { OrderItems.Add(new OrderItem(Id, productId, count)); } else { existingItems.ChangeCount(existingItems.Count + count); } TotalItemCount += count; }
public OrdersPageViewModel() { NotificationManager = new NotificationManager(); SelectedTable = Tables.FirstOrDefault(); SelectedOrderItem = OrderItems.FirstOrDefault(); }
public bool CanClear() { return(Quantity != 0 || SelectedTable != Tables.FirstOrDefault() || SelectedOrderItem != OrderItems.FirstOrDefault()); }
public void CreatePdf(IJSRuntime js) { var order = OrderItems.FirstOrDefault(); string OutputPath = $"Jegyek.pdf"; if (order != null) { OutputPath = $"Jegyek_{order.OrderId}.pdf"; } else { OutputPath = $"Jegyek.pdf"; } Filename = OutputPath; using (MemoryStream ms = new MemoryStream()) { Document pdfDoc = new Document(); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, ms); pdfDoc.Open(); float minheight = 40f; int counter = 0; foreach (var o in OrderItems) { for (int i = 0; i < o.Amount; i++) { PdfPTable table = new PdfPTable(4); table.WidthPercentage = 100f; table.SpacingAfter = 12.5f; var MyFont = FontFactory.GetFont("Times New Roman", 11, BaseColor.WHITE); var celldate = new PdfPCell(new Phrase($"{o.EventStartDate.Day}\n{CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(o.EventStartDate.Month)}", MyFont)); celldate.Rowspan = 3; celldate.BackgroundColor = BaseColor.BLACK; celldate.HorizontalAlignment = PdfPCell.ALIGN_CENTER; celldate.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; table.AddCell(celldate); var MyFont4 = FontFactory.GetFont("Times New Roman", 16, BaseColor.BLACK); var cellnama = new PdfPCell(new Phrase(o.EventName, MyFont4)); cellnama.Colspan = 2; cellnama.Border = PdfPCell.TOP_BORDER; table.AddCell(cellnama); var MyFont2 = FontFactory.GetFont("Times New Roman", 16, BaseColor.WHITE); var cellcategory = new PdfPCell(new Phrase(o.TicketCategory, MyFont2)); cellcategory.Rotation = 90; cellcategory.BackgroundColor = BaseColor.BLACK; cellcategory.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cellcategory.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cellcategory.Rowspan = 3; table.AddCell(cellcategory); var celllocation = new PdfPCell(new Phrase(o.EventLocation)); celllocation.Colspan = 2; celllocation.Border = PdfPCell.NO_BORDER; celllocation.BorderColor = BaseColor.WHITE; celllocation.MinimumHeight = minheight; table.AddCell(celllocation); var MyFont3 = FontFactory.GetFont("Times New Roman", 8, BaseColor.BLACK); var cellpriceandid = new PdfPCell(new Phrase($"{o.Price.ToString("N0")} Ft\n{o.OrderId}", MyFont3)); cellpriceandid.Colspan = 2; cellpriceandid.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cellpriceandid.Border = PdfPCell.BOTTOM_BORDER; cellpriceandid.MinimumHeight = minheight; table.AddCell(cellpriceandid); pdfDoc.Add(table); counter++; } } pdfWriter.CloseStream = false; pdfDoc.Close(); Generate(js, Filename, ms.GetBuffer()); } }