public void ComboButtonClickEvent(object sender, MenuSelectionEvent e) { if (e.fooditem is ComboOrder combo) // this will check if an object is a certain type { //newOrder.Add(combo.Entree); //newOrder.Add(combo.Drink); //newOrder.Add(combo.Side); newOrder.Add(combo); } DisplayCurrentOrder(); }
public AppOrder GetAppOrder(string packageName) { lock (orderingLockObj) { var order = Ordering.FirstOrDefault(ao => ao.PackageName.Equals(packageName)); // Make sure the current ordering actually exists if (order == null) { var index = 1; // If it doesn't exist, let's assume last in line var after = Ordering.LastOrDefault(); if (after != null) { index = after.Order + 1; } // Make our order order = new AppOrder { PackageName = packageName, Order = index }; // Order didn't exist so let's add it Ordering.Add(order); } return(order); } }
public void AddOrder(string key, bool desc = false) { Ordering.Add(new FilterOrder() { Key = key, Desc = desc }); }
public void When_AddingOrderByWithNonComparableProperty_Expect_PropertyNotComparableException() { // Arrange Ordering <TestClass> ordering = new Ordering <TestClass>(); // Act Exception exception = Record.Exception(() => ordering.Add(new OrderBy(nameof(TestClass.Property6)))); // Assert Assert.IsType <PropertyNotComparableException>(exception); }
public void When_AddingOrderByWithNonExistingProperty_Expect_PropertyNotFoundException() { // Arrange Ordering <TestClass> ordering = new Ordering <TestClass>(); // Act Exception exception = Record.Exception(() => ordering.Add(new OrderBy("property1"))); // Assert Assert.IsType <PropertyNotFoundException>(exception); }
public Selector <TField> AddOrderBy(TField field, bool isAsc) { var orderBy = new OrderBy(); orderBy.Field = field.ToString(); orderBy.SortOrder = isAsc ? SortOrder.Ascending : SortOrder.Descending; if (Ordering == null) { Ordering = new List <OrderBy>(); } Ordering.Add(orderBy); return(this); }
public virtual void ReadFrom(XElement xE) { Fields = null; Predicates = null; DateRange = null; Ordering = null; Paging = null; foreach (var xItem in xE.Elements()) { var localName = xItem.Name.LocalName; if (localName == "fields") { if (Fields == null) { Fields = new List <string>(); } Fields.Add(xItem.Value); } else if (localName == "predicates") { if (Predicates == null) { Predicates = new List <Predicate>(); } var predicatesItem = new Predicate(); predicatesItem.ReadFrom(xItem); Predicates.Add(predicatesItem); } else if (localName == "dateRange") { DateRange = new DateRange(); DateRange.ReadFrom(xItem); } else if (localName == "ordering") { if (Ordering == null) { Ordering = new List <OrderBy>(); } var orderingItem = new OrderBy(); orderingItem.ReadFrom(xItem); Ordering.Add(orderingItem); } else if (localName == "paging") { Paging = new Paging(); Paging.ReadFrom(xItem); } } }
public void When_OrderingContainsOrderBy_Expect_True() { // Arrange Ordering <TestClass> ordering = new Ordering <TestClass>(); OrderBy orderby = new OrderBy(nameof(TestClass.Property1)); ordering.Add(orderby); // Act bool result = ordering.Contains(orderby); // Assert Assert.True(result); }
public static Ordering GetOrderExpression <T>(this Request request) where T : class { var ordering = new Ordering(); if (request.Order.Count == 0) { return(ordering); } request.Order.ForEach(o => { var colName = request.Columns[o.Column].Data.ToUpperFirst(); if (!string.IsNullOrEmpty(colName)) { ordering.Add(new Tuple <string, string>(colName, o.Direction)); } }); return(ordering); }
public void OrderingShouldListenForPropertyChanges() { order.Add(newEntree); order.Add(newSide); order.Add(newDrink); Assert.PropertyChanged(order, "Subtotal", () => newSide.Size = Size.Large); Assert.PropertyChanged(order, "Subtotal", () => newSide.Size = Size.Medium); Assert.PropertyChanged(order, "Subtotal", () => newSide.Size = Size.Small); Assert.PropertyChanged(order, "Tax", () => newSide.Size = Size.Large); Assert.PropertyChanged(order, "Tax", () => newSide.Size = Size.Medium); Assert.PropertyChanged(order, "Tax", () => newSide.Size = Size.Small); Assert.PropertyChanged(order, "Total", () => newSide.Size = Size.Large); Assert.PropertyChanged(order, "Total", () => newSide.Size = Size.Medium); Assert.PropertyChanged(order, "Total", () => newSide.Size = Size.Small); Assert.PropertyChanged(order, "Calories", () => newSide.Size = Size.Large); Assert.PropertyChanged(order, "Calories", () => newSide.Size = Size.Medium); Assert.PropertyChanged(order, "Calories", () => newSide.Size = Size.Small); Assert.PropertyChanged(order, "Subtotal", () => newDrink.Size = Size.Large); Assert.PropertyChanged(order, "Subtotal", () => newDrink.Size = Size.Medium); Assert.PropertyChanged(order, "Subtotal", () => newDrink.Size = Size.Small); Assert.PropertyChanged(order, "Tax", () => newDrink.Size = Size.Large); Assert.PropertyChanged(order, "Tax", () => newDrink.Size = Size.Medium); Assert.PropertyChanged(order, "Tax", () => newDrink.Size = Size.Small); Assert.PropertyChanged(order, "Total", () => newDrink.Size = Size.Large); Assert.PropertyChanged(order, "Total", () => newDrink.Size = Size.Medium); Assert.PropertyChanged(order, "Total", () => newDrink.Size = Size.Small); Assert.PropertyChanged(order, "Calories", () => newDrink.Size = Size.Large); Assert.PropertyChanged(order, "Calories", () => newDrink.Size = Size.Medium); Assert.PropertyChanged(order, "Calories", () => newDrink.Size = Size.Small); }