public OrderItemViewModel(IOrderItem orderItem) { this.Id = orderItem.Guid.ToString(); this.Title = orderItem.Product.Title; this.Cost = orderItem.Product.Cost.ToString("C2"); this.Total = orderItem.Total.ToString("C2"); this.Quantity = orderItem.Quantity; this.Key = orderItem.Product.Title.ToUrl(); this.ProductGuid = orderItem.Product.Guid; this.IsHire = orderItem.Product.Type == ProductType.Hire; this.IsBuy = orderItem.Product.Type == ProductType.Buy; this.IsDelivery = orderItem.Product.Type == ProductType.Delivery; this.IsDiscount = orderItem.Product.Type == ProductType.Discount; this.IsTheme = orderItem.Product.Type == ProductType.Theme; this.Type = orderItem.Product.Type; if (orderItem.Product is Product) { Product product = orderItem.Product as Product; this.Description = product.Description; if (product.Images.Any()) { this.Thumbnail = product.Images.First().SecureThumbnail; } } if (orderItem.Product is Theme) { this.Thumbnail = (orderItem.Product as Theme).Images.First().ThumbnailUrl; this.Description = (orderItem.Product as Theme).Description; } }
public void CheckNotimplementExForCopyto() { Order a = new Order(); BriarheartBurger i = new BriarheartBurger(); IOrderItem[] array = new IOrderItem[15]; a.Add(i); var ex = Assert.Throws <NotImplementedException>(() => { a.CopyTo(array, 1); }); }
/// <summary> /// Method for opening the customization screens, with the given context /// </summary> /// <param name="item"></param> /// <param name="screen"></param> void AddItemAndOpenCustomizationScreen(IOrderItem item, FrameworkElement screen) { var orderCon = this.FindAncestor <OrderControl>(); if (DataContext is Order data) { item.CustomizationScreen = screen; screen.DataContext = item; data.Add(item); orderCon?.SwapScreen(screen); } }
public void uxEntree_Click(object sender, RoutedEventArgs e) { //if (sender is ComboBox ComboboxEntree && ComboBox.SelectedIndex) //{ IOrderItem item = (IOrderItem)((ComboBox)ComboboxEntree).SelectedItem; //entrees if (item is BriarheartBurger) { this.ancestor.screens.Remove(Screen.BBOptions); this.ancestor.screens.Add(Screen.BBOptions, new BBOptions((BriarheartBurger)ComboboxEntree.SelectedItem, this.ancestor, true, ComboboxEntree)); this.ancestor.SwitchScreen(Screen.BBOptions); } if (item is DoubleDraugr) { this.ancestor.screens.Remove(Screen.DDOptions); this.ancestor.screens.Add(Screen.DDOptions, new DDOptions((DoubleDraugr)ComboboxEntree.SelectedItem, this.ancestor, true, ComboboxEntree)); this.ancestor.SwitchScreen(Screen.DDOptions); } if (item is ThalmorTriple) { this.ancestor.screens.Remove(Screen.TTOptions); this.ancestor.screens.Add(Screen.TTOptions, new TTOptions((ThalmorTriple)ComboboxEntree.SelectedItem, this.ancestor, true, ComboboxEntree)); this.ancestor.SwitchScreen(Screen.TTOptions); } if (item is GardenOrcOmelette) { this.ancestor.screens.Remove(Screen.GORCOptions); this.ancestor.screens.Add(Screen.GORCOptions, new GORCOptions((GardenOrcOmelette)ComboboxEntree.SelectedItem, this.ancestor, true, ComboboxEntree)); this.ancestor.SwitchScreen(Screen.GORCOptions); } if (item is SmokehouseSkeleton) { this.ancestor.screens.Remove(Screen.SSOptions); this.ancestor.screens.Add(Screen.SSOptions, new SSOptions((SmokehouseSkeleton)ComboboxEntree.SelectedItem, this.ancestor, true, ComboboxEntree)); this.ancestor.SwitchScreen(Screen.SSOptions); } if (item is PhillyPoacher) { this.ancestor.screens.Remove(Screen.PPOptions); this.ancestor.screens.Add(Screen.PPOptions, new PPOptions((PhillyPoacher)ComboboxEntree.SelectedItem, this.ancestor, true, ComboboxEntree)); this.ancestor.SwitchScreen(Screen.PPOptions); } if (item is ThugsTBone) { this.ancestor.screens.Remove(Screen.TTBOptions); this.ancestor.screens.Add(Screen.TTBOptions, new TTBOptions((ThugsTBone)ComboboxEntree.SelectedItem, this.ancestor, true, ComboboxEntree)); this.ancestor.SwitchScreen(Screen.TTBOptions); } }
public DataOrderItem(IRetailOrder order, IOrderDetail detail, IOrderItem item) { OrderGuid = order.Guid; LocationGuid = detail.Location.Guid; PlaceCode = detail.PlaceCode; ProductGuid = item.Product.Guid; Quantity = item.Quantity; UnitPrice = item.UnitPrice; Discount = item.Discount; TotalPrice = item.TotalPrice; TaxValue = item.TaxValue; }
/// <summary> /// OrderSummaryControl.xaml.cs /// The helper method that will be in charge of switching the screen in the listItem_Click Event Handler. /// </summary> /// <param name="item">item the user selects</param> /// <param name="screen">screen the user wants to switch to</param> private void CustomizeItem(IOrderItem item, FrameworkElement screen) { var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order) { if (screen != null) { screen.DataContext = item; orderControl?.SwapScreen(screen); } } }
public AddOnPercentPromo(IOrderItem orderItem, int eligibleUnits, int salePercent) : base(orderItem) { if (salePercent < 0 || salePercent > 100) { throw new ArgumentException("salePercent argument must be in [0, 100]"); } if (eligibleUnits < 1) { throw new ArgumentException("eligibleUnits must be atleast 1"); } _eligibleUnits = eligibleUnits; _salePercent = salePercent; }
/// <summary> /// Remove an item from the list and returns if it could be removed. /// </summary> /// <param name="i"></param> /// <returns></returns> public bool Remove(IOrderItem i) { bool removed = items.Remove(i); if (removed) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SubtotalCost")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SalesTaxCost")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TotalCost")); } return(removed); }
public static IOrderItem AddCondimentToOrderItem(IOrderItem orderItem, string condimentName) { switch (condimentName) { case "Fries": return(new Fries(orderItem)); case "Rice": return(new Rice(orderItem)); } return(orderItem); }
/// <summary> /// Invokes property changed event when the subtotal, price, total, or calories changes /// </summary> /// <param name="item">Order item</param> public void Remove(IOrderItem item) { int index = Items.IndexOf(item); Items.Remove(item); item.PropertyChanged -= OnItemChanged; CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Tax")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Total")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Calories")); }
/// <summary> /// Removes an item from the order /// </summary> /// <param name="item"></param> public void Remove(IOrderItem item) { if (items.Contains(item)) { var itemIndex = items.IndexOf(item); items.Remove(item); CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Calories")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Tax")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Total")); } }
/// <summary> /// This method is used when wanting to cancel our current food order and /// switch to the menu screen from inside a descendant class of Order.xaml.cs /// It will also update the display for the current order items /// </summary> public void CancelCurrentCustomization(IOrderItem canceledItem) { //FoodReSelected?.Invoke(this, new MenuSelectionEvent() { fooditem = e.fooditem }); //int lastElement = newOrder.ListOrder.Count; //finalOrder.RemoveAt(lastElement-1); //IOrderItem canceledItem = newOrder.ListOrder[lastElement - 1]; newOrder.Remove(canceledItem); switchBorder.Child = menu; //most controls can only have one child DisplayCurrentOrder(); }
public void Test_CalculateTotal_WHEN_SKUComboPromotionsApply_THEN_TotalIsAdjusted() { var orderItems = new IOrderItem[] { GetSKUOrderItem(PromotionEngineTestContext.Products.C, 1), GetSKUOrderItem(PromotionEngineTestContext.Products.D, 1) }; var target = new OrderTotalCalculatorTestBuilder().Build(); var result = target.CalculateTotal(orderItems, PromotionEngineTestContext.ActivePromotions); Assert.AreEqual(30, result); }
public AddOnUnitPromo(IOrderItem orderItem, int eligibleUnits, int freeUnits) : base(orderItem) { if (eligibleUnits < 1) { throw new ArgumentException("eligibleUnits must be atleast 1"); } if (freeUnits < 1) { throw new ArgumentException("freeUnits must be atleast 1"); } _eligibleUnits = eligibleUnits; _freeUnits = freeUnits; }
public OrderController(IOrder order, IOrderComponent orderComponent, IOrderProduct orderProduct, IOrderInvoice orderInvoice, IOrderPayment orderPayment, IOrderItem orderitem, IMakerSheet makerSheet, IOrderService orderService) { _order = order; _orderComponent = orderComponent; _orderProduct = orderProduct; _orderInvoice = orderInvoice; _orderPayment = orderPayment; _orderItem = orderitem; _makerSheet = makerSheet; _orderService = orderService; }
/// <summary> /// adds items to the order /// </summary> /// <param name="item"> the item being added</param> public void Add(IOrderItem item) { currentListIndex = orders.Count; parent.SendButt.IsEnabled = false; orders.Add(item); _subTotal += item.Price; _totalCalories += item.Calories; NotifyPropertyChanged("_subTotal"); NotifyPropertyChanged("_tax"); NotifyPropertyChanged("_total"); NotifyPropertyChanged("_totalCalories"); parent.swapScreens(); }
/// <summary> /// removes an item from the order /// </summary> /// <param name="item"></param> /// <returns>whether the item was able to be removed</returns> public bool Remove(IOrderItem item) { bool removed = items.Remove(item); if (removed) { NotifyPropertyChanged("Items"); NotifyPropertyChanged("SubtotalCost"); NotifyPropertyChanged("SalesTaxCost"); NotifyPropertyChanged("TotalCost"); } return(removed); }
public void Test_ApplyPromotion_WHEN_ItemsButNoMatching_THEN_ItIsFailure() { var orderItems = new IOrderItem[] { GetSKUOrderItem(PromotionEngineTestContext.Products.A, 1), GetSKUOrderItem(PromotionEngineTestContext.Products.C, 2) }; var target = GetSingleSKUPromotion(PromotionEngineTestContext.Products.A.ID, 2, 80); var result = target.ApplyPromotion(orderItems); Assert.IsFalse(result.PromotionWasApplied); }
/// <summary> /// 檢驗優惠券是否適用於指定訂單項目 /// </summary> /// <param name="orderItem">訂單項目</param> /// <param name="order">訂單</param> /// <returns>是否適用</returns> private protected virtual bool IsAvailable(IOrder order, IOrderItem orderItem) { if (orderItem is IOrderItem <TOrderItemIdentifier> item) { return(Targets.Contains(item.Id)); } if (Count.HasValue && Count == 0) { return(false); } return(false); }
private bool DoesItemHaveSearchTerms(IOrderItem item) { string[] terms = SearchTerms.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string itemString = item.DisplayName + " " + item.Description; foreach (string term in terms) { if (!itemString.Contains(term, StringComparison.InvariantCultureIgnoreCase)) { return(false); } } return(true); }
/// <summary> /// Returns list as a string /// </summary> /// <param name="item"></param> /// <returns></returns> private string GetListAsString(IOrderItem item) { StringBuilder sb = new StringBuilder(); sb.Append("["); for (int i = 0; i < item.SpecialInstructions.Count; i++) { sb.Append(item.SpecialInstructions[i] + " "); } sb.Append("]"); string s = sb.ToString(); return(s); }
}//end OnGet() /// <summary> /// Builds the string that is displayed /// </summary> /// <param name="item">the item that you want displayed</param> /// <returns>returns string to display</returns> public static string BuildString(IOrderItem item) { StringBuilder sb = new StringBuilder(); //name of item, price, and calories string name = item.GetType().Name; foreach (PropertyInfo pi in item.GetType().GetProperties()) { if (pi.Name.ToLower() == "size") { dynamic dynamicItem = item; sb.Append($"{dynamicItem.Size}"); }//end if this property is the size property }//end looping foreach property in the item's type foreach (PropertyInfo pi in item.GetType().GetProperties()) { if (pi.Name.ToLower() == "flavor") { dynamic dynamicItem = item; sb.Append($" {dynamicItem.Flavor}"); }//end if this property is the flavor property }//end looping foreach property in the item's type foreach (PropertyInfo pi in item.GetType().GetProperties()) { if (pi.Name.ToLower() == "decaf") { dynamic dynamicItem = item; if(dynamicItem.Decaf = true) { sb.Append($" Decaf"); }//end if the item is decafinated }//end if this property is the flavor property }//end looping foreach property in the item's type for (int i = 0; i < name.Length; i++) { if (Char.IsUpper(name[i]) && sb.Length != 0) sb.Append(" "); sb.Append(name[i]); }//end looping for each character in name sb.Append(": "); sb.Append(item.Description); sb.Append("\t"); sb.Append(item.Calories); sb.Append(" Cals\t"); sb.Append(item.Price.ToString("C2")); return sb.ToString(); }//end BuildString(item, hasSizeProperty)
public OrderItemViewModel(IOrderItem orderItem) { this.Id = orderItem.Guid.ToString(); this.Title = orderItem.Product.Title; this.Cost = orderItem.Product.Cost.ToString("C2"); this.Total = orderItem.Total.ToString("C2"); this.Quantity = orderItem.Quantity; this.Key = orderItem.Product.Title.ToUrl(); this.ProductGuid = orderItem.Product.Guid; this.IsHire = orderItem.Product.Type == ProductType.Hire; this.IsBuy = orderItem.Product.Type == ProductType.Buy; this.IsDelivery = orderItem.Product.Type == ProductType.Delivery; this.IsDiscount = orderItem.Product.Type == ProductType.Discount; this.Type = orderItem.Product.Type; }
void DoneClickHandle(object sender, EventArgs e) { if (mainWindow.DataContext is Order order) { IOrderItem item = order.Last(); if (item is Combo) { this.mainWindow.SwitchScreen("comboCustom"); } else { this.mainWindow.SwitchScreen("menuSelect"); } } }
private void DeleteItemButton_Click(object sender, RoutedEventArgs e) { if (DataContext is Order data) { if (sender is Button) { IOrderItem item = ((sender as ListBox).SelectedItem as IOrderItem); FrameworkElement screen = null; var orderControl = this.FindAncestor <OrderControl>(); //Cast sender to button Button b = (Button)sender; } } }
public OrderItemModel(IOrderItem row) { Quantity = row.Quantity; UnitPrice = row.UnitPrice; UnitCode = row.Product.UnitCode; UnitWeight = row.Product.UnitWeight; Weights = row.Product.Weights; Discount = row.Discount; TotalPrice = row.TotalPrice; TaxValue = row.TaxValue; Guid = row.Product.Guid; Name = row.Product.Name; }
public void Test_CalculateTotal_WHEN_NoPromotionsApply_THEN_TotalIsUnaffected() { // scenario A var orderItems = new IOrderItem[] { GetSKUOrderItem(PromotionEngineTestContext.Products.A, 1), GetSKUOrderItem(PromotionEngineTestContext.Products.B, 1), GetSKUOrderItem(PromotionEngineTestContext.Products.C, 1) }; var target = new OrderTotalCalculatorTestBuilder().Build(); var result = target.CalculateTotal(orderItems, PromotionEngineTestContext.ActivePromotions); Assert.AreEqual(100, result); }
public void Test_CalculateTotal_WHEN_SingleSKUPromotionsApplyTo2Items_THEN_TotalIsAdjusted() { // scenario B var orderItems = new IOrderItem[] { GetSKUOrderItem(PromotionEngineTestContext.Products.A, 5), GetSKUOrderItem(PromotionEngineTestContext.Products.B, 5), GetSKUOrderItem(PromotionEngineTestContext.Products.C, 1) }; var target = new OrderTotalCalculatorTestBuilder().Build(); var result = target.CalculateTotal(orderItems, PromotionEngineTestContext.ActivePromotions); Assert.AreEqual(370, result); }
/// <summary> /// Remove and item from the order and stop editing it if we are /// </summary> /// <param name="item">Item to remove</param> public void RemoveAndStopEditing(IOrderItem item) { if (SelectHolder.Content is ModifyItemControl modView) { if (modView.DataContext is IOrderItem editItem) { if (editItem == item) { SwapScreen(new MenuItemSelectionControl()); } } } (DataContext as Order).Remove(item); }
/// <summary> /// Opens the Customization screen /// </summary> /// <param name="item">Order Item being accessed</param> /// <param name="screen">Screen being opened</param> private void OpenCustomizationScreen(IOrderItem item, FrameworkElement screen) { // Not all OrderItems need to be customized if (screen != null) { // We need to have OrderControl ancestor to load the cusomization screen var orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected, instead was null"); } screen.DataContext = item; orderControl.SwapScreen(screen); } }
void OrderListSelectionChange(object sender, SelectionChangedEventArgs e) { FrameworkElement elem; IOrderItem item = (IOrderItem)((ListBox)sender).SelectedItem; var orderControl = this.FindAncestor <OrderControl>(); if (item != null) { elem = (FrameworkElement)item.Display; } else { elem = new MenuSelection(); } orderControl?.DisplayUpdate(elem); }
public void Test_ApplyPromotion_WHEN_ItemMatchesAndTriggers2Promotions_THEN_ItReturnsAdjustmentOf40() { var orderItems = new IOrderItem[] { GetSKUOrderItem(PromotionEngineTestContext.Products.A, 5), GetSKUOrderItem(PromotionEngineTestContext.Products.C, 2) }; var target = GetSingleSKUPromotion(PromotionEngineTestContext.Products.A.ID, 2, 80); var result = target.ApplyPromotion(orderItems); Assert.IsTrue(result.PromotionWasApplied); Assert.AreEqual(-40, result.AdjustmentOrderItem.Amount); Assert.AreEqual(PromotionEngineTestContext.Products.A, result.AppliedToSKUs.Single()); }
public OrderItemViewModel(IOrderItem orderItem) { this.Id = orderItem.Guid.ToString(); this.Title = orderItem.Product.Title; this.Cost = orderItem.Product.Cost.ToString("C2"); this.Total = orderItem.Total.ToString("C2"); this.Quantity = orderItem.Quantity; this.Key = orderItem.Product.Title.ToUrl(); this.ProductGuid = orderItem.Product.Guid; this.IsHire = orderItem.Product.Type == ProductType.Hire; this.IsBuy = orderItem.Product.Type == ProductType.Buy; this.IsDelivery = orderItem.Product.Type == ProductType.Delivery; this.IsDiscount = orderItem.Product.Type == ProductType.Discount; this.IsTheme = orderItem.Product.Type == ProductType.Theme; this.Type = orderItem.Product.Type; if (orderItem.Product is IProduct) { IProduct product = orderItem.Product as IProduct; if (product.Images.Any()) { this.Thumbnail = product.Images.First().SecureThumbnail; } } if (orderItem.Product is Theme) { this.Thumbnail = (orderItem.Product as Theme).Images.First().ThumbnailUrl; } if (orderItem.Product is LoyaltyCard) { var loyaltyCard = orderItem.Product as LoyaltyCard; if(loyaltyCard.LoyaltyCardType == Rabbit.Orders.Enums.LoyaltyCardType.Percentage) { this.Cost = loyaltyCard.Discount.ToString("0") + "%"; } } }
public void removeOrderItem(IOrderItem item) { throw new System.NotImplementedException(); }
internal void Sold(IOrderItem orderItem) { this.Status = InventoryStatus.Sold; this.DateSold = DateTime.Now; this.OrderItemGuid = orderItem.Guid; }