public MenuItemGroupedPropertyViewModel(TicketItemViewModel selectedItem, IGrouping<string, MenuItemPropertyGroup> menuItemPropertyGroups) { Name = menuItemPropertyGroups.Key; Properties = menuItemPropertyGroups.Select(x => new MenuItemGroupedPropertyItemViewModel(selectedItem, x)).ToList(); ColumnCount = menuItemPropertyGroups.First().ColumnCount; ButtonHeight = menuItemPropertyGroups.First().ButtonHeight; TerminalButtonHeight = menuItemPropertyGroups.First().TerminalButtonHeight; TerminalColumnCount = menuItemPropertyGroups.First().TerminalColumnCount; }
public MenuItemGroupedPropertyViewModel(TicketItemViewModel selectedItem, IGrouping <string, MenuItemPropertyGroup> menuItemPropertyGroups) { Name = menuItemPropertyGroups.Key; Properties = menuItemPropertyGroups.Select(x => new MenuItemGroupedPropertyItemViewModel(selectedItem, x)).ToList(); ColumnCount = menuItemPropertyGroups.First().ColumnCount; ButtonHeight = menuItemPropertyGroups.First().ButtonHeight; TerminalButtonHeight = menuItemPropertyGroups.First().TerminalButtonHeight; TerminalColumnCount = menuItemPropertyGroups.First().TerminalColumnCount; }
public TicketItemViewModel AddNewItem(int menuItemId, decimal quantity, bool gift, string defaultProperties, string portionName) { if (!Model.CanSubmit) { return(null); } ClearSelectedItems(); var menuItem = AppServices.DataAccessService.GetMenuItem(menuItemId); if (menuItem.Portions.Count == 0) { return(null); } var portion = menuItem.Portions[0]; if (!string.IsNullOrEmpty(portionName) && menuItem.Portions.Count(x => x.Name == portionName) > 0) { portion = menuItem.Portions.First(x => x.Name == portionName); } var departmentId = AppServices.CurrentTerminal.DepartmentId > 0 ? AppServices.MainDataContext.SelectedDepartment.Id : Model.DepartmentId; var ti = Model.AddTicketItem(AppServices.CurrentLoggedInUser.Id, departmentId, menuItem, portion.Name, AppServices.MainDataContext.SelectedDepartment.PriceTag, defaultProperties); ti.Quantity = quantity > 9 ? decimal.Round(quantity / portion.Multiplier, LocalSettings.Decimals) : quantity; ti.Gifted = gift; var ticketItemViewModel = new TicketItemViewModel(ti); _items.Add(ticketItemViewModel); RecalculateTicket(); RuleExecutor.NotifyEvent(RuleEventNames.TicketLineAdded, new { Ticket = AppServices.MainDataContext.SelectedTicket, TicketItem = ti, TicketId = AppServices.MainDataContext.SelectedTicket.Id, TicketTag = AppServices.MainDataContext.SelectedTicket.Tag, Quantity = quantity, Model.CustomerId, Model.CustomerName, Model.CustomerGroupCode, MenuItemName = menuItem.Name, MenuItemGroupCode = menuItem.GroupCode }); ticketItemViewModel.PublishEvent(EventTopicNames.TicketItemAdded); return(ticketItemViewModel); }
private void OnItemSelected(TicketItemViewModel obj) { if (Selected && !IsLocked) { var unselectedItem = AppServices.DataAccessService.GetUnselectedItem(obj.Model); if (unselectedItem != null) { InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.SelectionRequired_f, unselectedItem.Name)); return; } } Selected = !Selected; if (!Selected) { ResetSelectedQuantity(); } this.PublishEvent(EventTopicNames.SelectedItemsChanged); }
void MenuItemSelectorViewModel_OnTicketItemSelected(TicketItemViewModel item) { ActivateSelectedTicketItemEditorView(item, null); }
private void ActivateSelectedTicketItemEditorView(TicketItemViewModel item, TicketTagGroup selectedTicketTag) { SelectedIndex = 5; SelectedTicketItemEditorViewModel.Refresh(item, selectedTicketTag); }
private void OnItemSelected(TicketItemViewModel obj) { InvokeOnTicketItemSelected(obj); }
public void InvokeOnTicketItemSelected(TicketItemViewModel ticketItem) { TicketItemSelectedEventHandler handler = OnTicketItemSelected; if (handler != null) handler(ticketItem); }
public TicketItemViewModel AddNewItem(int menuItemId, decimal quantity, bool gift, string defaultProperties, string portionName) { if (!Model.CanSubmit) return null; ClearSelectedItems(); var menuItem = AppServices.DataAccessService.GetMenuItem(menuItemId); if (menuItem.Portions.Count == 0) return null; var portion = menuItem.Portions[0]; if (!string.IsNullOrEmpty(portionName) && menuItem.Portions.Count(x => x.Name == portionName) > 0) { portion = menuItem.Portions.First(x => x.Name == portionName); } var departmentId = AppServices.CurrentTerminal.DepartmentId > 0 ? AppServices.MainDataContext.SelectedDepartment.Id : Model.DepartmentId; var ti = Model.AddTicketItem(AppServices.CurrentLoggedInUser.Id, departmentId, menuItem, portion.Name, AppServices.MainDataContext.SelectedDepartment.PriceTag, defaultProperties); ti.Quantity = quantity > 9 ? decimal.Round(quantity / portion.Multiplier, LocalSettings.Decimals) : quantity; ti.Gifted = gift; var ticketItemViewModel = new TicketItemViewModel(ti); _items.Add(ticketItemViewModel); RecalculateTicket(); RuleExecutor.NotifyEvent(RuleEventNames.TicketLineAdded, new { Ticket = AppServices.MainDataContext.SelectedTicket, TicketItem = ti, TicketId = AppServices.MainDataContext.SelectedTicket.Id, TicketTag = AppServices.MainDataContext.SelectedTicket.Tag, Quantity = quantity, Model.CustomerId, Model.CustomerName, Model.CustomerGroupCode, MenuItemName = menuItem.Name, MenuItemGroupCode = menuItem.GroupCode }); ticketItemViewModel.PublishEvent(EventTopicNames.TicketItemAdded); return ticketItemViewModel; }
public MenuItemGroupedPropertyItemViewModel(TicketItemViewModel selectedItem, MenuItemPropertyGroup menuItemPropertyGroup) { _selectedItem = selectedItem; MenuItemPropertyGroup = menuItemPropertyGroup; UpdateNextProperty(null); }
private void OnItemSelected(TicketItemViewModel obj) { if (Selected && !IsLocked) { var unselectedItem = AppServices.DataAccessService.GetUnselectedItem(obj.Model); if (unselectedItem != null) { InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.SelectionRequired_f, unselectedItem.Name)); return; } } Selected = !Selected; if (!Selected) ResetSelectedQuantity(); this.PublishEvent(EventTopicNames.SelectedItemsChanged); }
public void Refresh(TicketItemViewModel ticketItem, TicketTagGroup selectedTicketTag) { HideKeyboard(); SelectedTicketTag = null; SelectedItemPortions.Clear(); SelectedItemPropertyGroups.Clear(); SelectedItemGroupedPropertyItems.Clear(); TicketTags.Clear(); SelectedItem = ticketItem; if (ticketItem != null) { var mi = AppServices.DataAccessService.GetMenuItem(ticketItem.Model.MenuItemId); if (mi.Portions.Count > 1) SelectedItemPortions.AddRange(mi.Portions.Select(x => new MenuItemPortionViewModel(x))); SelectedItemGroupedPropertyItems.AddRange(mi.PropertyGroups.Where(x => !string.IsNullOrEmpty(x.GroupTag)) .GroupBy(x => x.GroupTag) .Select(x => new MenuItemGroupedPropertyViewModel(SelectedItem, x))); SelectedItemPropertyGroups.AddRange(mi.PropertyGroups .Where(x => string.IsNullOrEmpty(x.GroupTag)) .Select(x => new MenuItemPropertyGroupViewModel(x))); foreach (var ticketItemPropertyViewModel in ticketItem.Properties.ToList()) { var tip = ticketItemPropertyViewModel; var mig = SelectedItemPropertyGroups.Where(x => x.Model.Id == tip.Model.PropertyGroupId).SingleOrDefault(); if (mig != null) mig.Properties.SingleOrDefault(x => x.Name == tip.Model.Name).TicketItemProperty = ticketItemPropertyViewModel.Model; var sig = SelectedItemGroupedPropertyItems.SelectMany(x => x.Properties).Where( x => x.MenuItemPropertyGroup.Id == tip.Model.PropertyGroupId).FirstOrDefault(); if (sig != null) sig.TicketItemProperty = ticketItemPropertyViewModel.Model; } } else { if (selectedTicketTag != null) { SelectedTicketTag = selectedTicketTag; if (selectedTicketTag.FreeTagging) { TicketTags.AddRange(Dao.Query<TicketTagGroup>(x => x.Id == selectedTicketTag.Id, x => x.TicketTags).SelectMany(x => x.TicketTags).OrderBy(x => x.Name).Select(x => new TicketTagViewModel(x))); } else { TicketTags.AddRange(selectedTicketTag.TicketTags.Select(x => new TicketTagViewModel(x))); } RaisePropertyChanged("TicketTags"); } else { RaisePropertyChanged("TicketNote"); ShowKeyboard(); } } RaisePropertyChanged("SelectedItem"); RaisePropertyChanged("IsPortionsVisible"); RaisePropertyChanged("IsEditorsVisible"); RaisePropertyChanged("IsTicketNoteVisible"); RaisePropertyChanged("IsTagEditorVisible"); RaisePropertyChanged("IsFreeTagEditorVisible"); RaisePropertyChanged("TagColumnCount"); }