public bool ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId) { var result = true; var otag = OrderTagValues.FirstOrDefault(x => x.Name == orderTag.Name); if (otag == null) { if (orderTagGroup.MaxSelectedItems > 1 && OrderTagValues.Count(x => x.OrderTagGroupId == orderTagGroup.Id) >= orderTagGroup.MaxSelectedItems) { return(false); } var tagIndex = -1; if (orderTagGroup.MaxSelectedItems == 1) { var sTag = OrderTagValues.SingleOrDefault(x => x.OrderTagGroupId == orderTag.OrderTagGroupId); if (sTag != null) { tagIndex = OrderTagValues.IndexOf(sTag); } OrderTagValues.Where(x => x.OrderTagGroupId == orderTagGroup.Id).ToList().ForEach(x => OrderTagValues.Remove(x)); } TagOrder(orderTagGroup, orderTag, userId, tagIndex); } else { otag.Quantity++; if (orderTagGroup.MaxSelectedItems == 1 || (orderTag.MaxQuantity > 0 && otag.Quantity > orderTag.MaxQuantity)) { UntagOrder(otag); result = false; } } return(result); }
private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex, string tagNote) { var otag = new OrderTagValue { TagValue = orderTag.Name, OrderTagGroupId = orderTagGroup.Id, TagName = orderTagGroup.Name, TagNote = !string.IsNullOrEmpty(tagNote) ? tagNote : null, MenuItemId = orderTag.MenuItemId, AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice, PortionName = orderTag.MenuItemId > 0 ? PortionName : null, UserId = userId, Quantity = 1, OrderKey = orderTagGroup.SortOrder.ToString("000") + orderTag.SortOrder.ToString("000") }; otag.UpdatePrice(orderTag.Price); if (tagIndex > -1) { OrderTagValues.Insert(tagIndex, otag); } else { OrderTagValues.Add(otag); } OrderTags = JsonHelper.Serialize(OrderTagValues); _orderTagValues = null; }
public void TagIfNotTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId) { if (OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name) == null) { ToggleOrderTag(orderTagGroup, orderTag, userId); } }
private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex) { var otag = new OrderTagValue { Name = orderTag.Name, OrderTagGroupId = orderTagGroup.Id, OrderTagGroupName = orderTagGroup.Name, MenuItemId = orderTag.MenuItemId, AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice, PortionName = PortionName, SubValue = !string.IsNullOrEmpty(orderTagGroup.ButtonHeader) && orderTag.Price == 0 && orderTagGroup.MaxSelectedItems == 1, UserId = userId, Quantity = 1, NewTag = true, OrderKey = orderTagGroup.Order.ToString("000") + orderTag.Order.ToString("000") }; otag.UpdatePrice(TaxIncluded, TaxRate, orderTag.Price); if (tagIndex > -1) { OrderTagValues.Insert(tagIndex, otag); } else { OrderTagValues.Add(otag); } }
public OrderTagButtonViewModel(IEnumerable<Order> selectedOrders, OrderTagGroup tagGroup, OrderTag model) { _selectedOrders = selectedOrders; Model = model; OrderTagGroup = tagGroup; if (string.IsNullOrEmpty(model.Name)) model.Name = string.Format("[{0}]", Resources.NewProperty); }
public void UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag) { var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name); if (value != null) { UntagOrder(value); } }
public bool UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag) { var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.TagValue == orderTag.Name); if (value != null) { UntagOrder(value); return(true); } return(false); }
private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex) { var otag = new OrderTagValue { Name = orderTag.Name, OrderTagGroupId = orderTagGroup.Id, OrderTagGroupName = orderTagGroup.Name, MenuItemId = orderTag.MenuItemId, AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice, PortionName = PortionName, SubValue = !string.IsNullOrEmpty(orderTagGroup.ButtonHeader) && orderTag.Price == 0 && orderTagGroup.MaxSelectedItems == 1, UserId = userId, Quantity = 1, NewTag = true, OrderKey = orderTagGroup.Order.ToString("000") + orderTag.Order.ToString("000") }; otag.UpdatePrice(TaxIncluded, TaxRate, orderTag.Price); if (tagIndex > -1) OrderTagValues.Insert(tagIndex, otag); else OrderTagValues.Add(otag); }
public void UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag) { var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name); if (value != null) UntagOrder(value); }
public bool ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId) { var result = true; var otag = OrderTagValues.FirstOrDefault(x => x.Name == orderTag.Name); if (otag == null) { if (orderTagGroup.MaxSelectedItems > 1 && OrderTagValues.Count(x => x.OrderTagGroupId == orderTagGroup.Id) >= orderTagGroup.MaxSelectedItems) return false; var tagIndex = -1; if (orderTagGroup.MaxSelectedItems == 1) { var sTag = OrderTagValues.SingleOrDefault(x => x.OrderTagGroupId == orderTag.OrderTagGroupId); if (sTag != null) tagIndex = OrderTagValues.IndexOf(sTag); OrderTagValues.Where(x => x.OrderTagGroupId == orderTagGroup.Id).ToList().ForEach(x => OrderTagValues.Remove(x)); } TagOrder(orderTagGroup, orderTag, userId, tagIndex); } else { otag.Quantity++; if (orderTagGroup.MaxSelectedItems == 1 || (orderTag.MaxQuantity > 0 && otag.Quantity > orderTag.MaxQuantity)) { UntagOrder(otag); result = false; } } return result; }
public void TagIfNotTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId) { if (OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name) == null) { ToggleOrderTag(orderTagGroup, orderTag, userId); } }
public GroupedOrderTagButtonViewModel(Order selectedItem, OrderTagGroup orderTagGroup) { _selectedItem = selectedItem; OrderTagGroup = orderTagGroup; UpdateNextTag(null); }
public bool IsTaggedWith(OrderTagGroup orderTagGroup) { return Model.IsTaggedWith(orderTagGroup); }
public void TagOrders(Ticket ticket, IEnumerable<Order> selectedOrders, OrderTagGroup orderTagGroup, OrderTag orderTag, string tagNote) { var so = selectedOrders.ToList(); if (orderTagGroup.MaxSelectedItems == 1) { foreach (var order in so.Where(x => x.OrderTagExists(y => y.OrderTagGroupId == orderTagGroup.Id && y.TagValue != orderTag.Name))) { var orderTagValue = order.GetOrderTagValues().First(x => x.OrderTagGroupId == orderTagGroup.Id); order.UntagOrder(orderTagValue); _applicationState.NotifyEvent(RuleEventNames.OrderUntagged, new { Ticket = ticket, Order = order, OrderTagName = orderTagGroup.Name, OrderTagValue = orderTagValue.TagValue }); } } foreach (var selectedOrder in so) { var result = selectedOrder.ToggleOrderTag(orderTagGroup, orderTag, _applicationState.CurrentLoggedInUser.Id, tagNote); if (orderTagGroup.SaveFreeTags && orderTagGroup.OrderTags.All(x => x.Name != orderTag.Name)) { _ticketDao.SaveFreeOrderTag(orderTagGroup.Id, orderTag); _cacheService.ResetOrderTagCache(); } _applicationState.NotifyEvent(result ? RuleEventNames.OrderTagged : RuleEventNames.OrderUntagged, new { Ticket = ticket, Order = selectedOrder, OrderTagName = orderTagGroup.Name, OrderTagValue = orderTag.Name }); } }
public void UntagOrders(Ticket ticket, IEnumerable<Order> selectedOrders, OrderTagGroup orderTagGroup, OrderTag orderTag) { foreach (var selectedOrder in selectedOrders.Where(selectedOrder => selectedOrder.UntagIfTagged(orderTagGroup, orderTag))) { _applicationState.NotifyEvent(RuleEventNames.OrderUntagged, new { Ticket = ticket, Order = selectedOrder, OrderTagName = orderTagGroup.Name, OrderTagValue = orderTag.Name }); } }
public OrderTagGroupViewModel(OrderTagGroup model, IEnumerable<Order> selectedOrders) { Model = model; _selectedOrders = selectedOrders; }
private static IEnumerable<OrderTagButtonViewModel> GetOrderTags(IEnumerable<Order> selectedOrders, OrderTagGroup baseModel) { return baseModel.OrderTags.Select(item => new OrderTagButtonViewModel(selectedOrders, baseModel, item)); }
public void UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId) { var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name); if (value != null) ToggleOrderTag(orderTagGroup, orderTag, userId); }
private bool CanShowOrderTagsExecute(OrderTagGroup arg) { return SelectedOrders.Any(); }
public void ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId) { var result = _model.ToggleOrderTag(orderTagGroup, orderTag, userId); _automationService.NotifyEvent(result ? RuleEventNames.OrderTagged : RuleEventNames.OrderUntagged, new { Order = Model, OrderTagName = orderTagGroup.Name, OrderTagValue = orderTag.Name }); RefreshProperties(); RaisePropertyChanged(() => TotalPrice); RaisePropertyChanged(() => Quantity); RaisePropertyChanged(() => Description); RaisePropertyChanged(() => FontWeight); RaisePropertyChanged(() => IsLocked); }
private void OnShowOrderTagsExecute(OrderTagGroup orderTagGroup) { var orderTagData = new OrderTagData { SelectedOrders = SelectedOrders, OrderTagGroup = orderTagGroup, Ticket = SelectedTicket }; orderTagData.PublishEvent(EventTopicNames.SelectOrderTag); }
public static OrderTag AddDefaultMenuItemProperty(OrderTagGroup item) { return item.AddOrderTag("", 0); }
private bool CanShowOrderTagsExecute(OrderTagGroup arg) { if (SelectedOrders.Count() == 0) return false; if (!arg.DecreaseOrderInventory && SelectedOrders.Any(x => !x.Locked && !x.IsTaggedWith(arg))) return false; if (SelectedOrders.Any(x => !x.DecreaseInventory && !x.IsTaggedWith(arg))) return false; return !arg.UnlocksOrder || !SelectedOrders.Any(x => x.Locked && x.OrderTagValues.Count(y => y.OrderTagGroupId == arg.Id) > 0); }
public OrderTagGroupButton(OrderTagGroup orderTagGroup) { Model = orderTagGroup; Name = Model.Name; }
public bool UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag) { var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.TagValue == orderTag.Name); if (value != null) { UntagOrder(value); return true; } return false; }
private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex) { var otag = new OrderTagValue { Name = orderTag.Name, OrderTagGroupId = orderTagGroup.Id, MenuItemId = orderTag.MenuItemId, AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice, PortionName = PortionName, UserId = userId, DecreaseInventory = orderTagGroup.DecreaseOrderInventory, CalculatePrice = orderTagGroup.CalculateOrderPrice, Quantity = 1, UnlocksOrder = orderTagGroup.UnlocksOrder, NewTag = true }; otag.UpdatePrice(TaxIncluded, TaxRate, orderTag.Price); if (tagIndex > -1) OrderTagValues.Insert(tagIndex, otag); else OrderTagValues.Add(otag); CalculatePrice = orderTagGroup.CalculateOrderPrice; DecreaseInventory = orderTagGroup.DecreaseOrderInventory; if (orderTagGroup.UnlocksOrder) Locked = false; }
public bool IsTaggedWith(OrderTagGroup orderTagGroup) { return(OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null); }
private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex, string tagNote) { var otag = new OrderTagValue { TagValue = orderTag.Name, OrderTagGroupId = orderTagGroup.Id, TagName = orderTagGroup.Name, TagNote = !string.IsNullOrEmpty(tagNote) ? tagNote : null, MenuItemId = orderTag.MenuItemId, AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice, PortionName = orderTag.MenuItemId > 0 ? PortionName : null, UserId = userId, Quantity = 1, OrderKey = orderTagGroup.SortOrder.ToString("000") + orderTag.SortOrder.ToString("000") }; otag.UpdatePrice(orderTag.Price); if (tagIndex > -1) OrderTagValues.Insert(tagIndex, otag); else OrderTagValues.Add(otag); OrderTags = JsonHelper.Serialize(OrderTagValues); _orderTagValues = null; }
public bool IsTaggedWith(OrderTagGroup orderTagGroup) { return OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null; }
public OrderTagButton(OrderTagGroup orderTagGroup) { Model = orderTagGroup; Name = Model.ButtonHeader; }