private static void HandleEvents() { EventServiceFactory.EventService.GetEvent <GenericEvent <ActionData> >().Subscribe(x => { if (x.Value.Action.ActionType == "UpdateApplicationSubTitle") { var title = x.Value.GetAsString("Title"); PresentationServices.SubTitle.ApplicationTitle = title; var fontSize = x.Value.GetAsInteger("FontSize"); if (fontSize > 0) { PresentationServices.SubTitle.ApplicationTitleFontSize = fontSize; } var fontColor = x.Value.GetAsString("Color"); if (!string.IsNullOrEmpty(fontColor)) { PresentationServices.SubTitle.ApplicationTitleColor = fontColor; } } if (x.Value.Action.ActionType == "RemoveLastModifier") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket == null) { return; } var ti = x.Value.GetDataValue <TicketItem>("TicketItem"); if (ti == null) { return; } if (ti.Properties.Count > 0) { var prop = ti.LastSelectedProperty ?? ti.Properties.Last(); prop.Quantity--; if (prop.Quantity < 1) { ti.Properties.Remove(prop); } } TicketViewModel.RecalculateTicket(ticket); } if (x.Value.Action.ActionType == "UpdateTicketItemPriceTag") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket == null) { return; } var ti = x.Value.GetDataValue <TicketItem>("TicketItem"); if (ti == null) { return; } var priceTag = x.Value.GetAsString("PriceTag"); var mi = AppServices.DataAccessService.GetMenuItem(ti.MenuItemId); if (mi == null) { return; } var portion = mi.Portions.SingleOrDefault(y => y.Name == ti.PortionName); if (portion == null) { return; } ti.UpdatePortion(portion, priceTag, null); TicketViewModel.RecalculateTicket(ticket); EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } if (x.Value.Action.ActionType == "UpdateTicketItemTag") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket == null) { return; } var ti = x.Value.GetDataValue <TicketItem>("TicketItem"); if (ti == null) { return; } var tag = x.Value.GetAsString("Tag"); ti.Tag = tag; decimal val; decimal.TryParse(tag, out val); } if (x.Value.Action.ActionType == "UpdateLastTicketItemPriceTag") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket == null) { return; } var ti = ticket.TicketItems.LastOrDefault(); if (ti == null) { return; } var priceTag = x.Value.GetAsString("PriceTag"); var mi = AppServices.DataAccessService.GetMenuItem(ti.MenuItemId); if (mi == null) { return; } var portion = mi.Portions.SingleOrDefault(y => y.Name == ti.PortionName); if (portion == null) { return; } ti.UpdatePortion(portion, priceTag, null); TicketViewModel.RecalculateTicket(ticket); EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } if (x.Value.Action.ActionType == "GiftLastTicketItem") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var ti = ticket.TicketItems.LastOrDefault(); if (ti != null) { decimal quantity; decimal.TryParse(x.Value.Action.GetParameter("Quantity"), out quantity); if (quantity > 0 && ti.Quantity > quantity) { ti.UpdateSelectedQuantity(quantity); ti = ticket.ExtractSelectedTicketItems(new List <TicketItem> { ti }).FirstOrDefault(); if (ti == null) { return; } AppServices.MainDataContext.AddItemToSelectedTicket(ti); } var reasonId = 0; var giftReason = x.Value.Action.GetParameter("GiftReason"); if (!string.IsNullOrEmpty(giftReason)) { var reason = Dao.SingleWithCache <Reason>(u => u.Name == giftReason); if (reason != null) { reasonId = reason.Id; } } ticket.GiftItem(ti, reasonId, AppServices.CurrentLoggedInUser.Id); TicketViewModel.RecalculateTicket(ticket); EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } } } if (x.Value.Action.ActionType == "UpdateTicketAccount") { Expression <Func <Customer, bool> > qFilter = null; var phoneNumber = x.Value.GetAsString("AccountPhone"); var accountName = x.Value.GetAsString("AccountName"); var note = x.Value.GetAsString("Note"); if (!string.IsNullOrEmpty(phoneNumber)) { qFilter = y => y.PhoneNumber == phoneNumber; } if (!string.IsNullOrEmpty(accountName)) { if (qFilter == null) { qFilter = y => y.Name == accountName; } else { qFilter = qFilter.And(y => y.Name == accountName); } } if (!string.IsNullOrEmpty(note)) { if (qFilter == null) { qFilter = y => y.Note == note; } else { qFilter = qFilter.And(y => y.Note == note); } } if (qFilter != null) { var customer = Dao.Query(qFilter).FirstOrDefault(); if (customer != null) { AppServices.MainDataContext.AssignCustomerToSelectedTicket(customer); } } else { AppServices.MainDataContext.AssignCustomerToSelectedTicket(Customer.Null); } } if (x.Value.Action.ActionType == "UpdateProgramSetting") { SettingAccessor.ResetCache(); var settingName = x.Value.GetAsString("SettingName"); var updateType = x.Value.GetAsString("UpdateType"); if (!string.IsNullOrEmpty(settingName)) { var isLocal = x.Value.GetAsBoolean("IsLocal"); var setting = isLocal ? AppServices.SettingService.ReadLocalSetting(settingName) : AppServices.SettingService.ReadGlobalSetting(settingName); if (updateType == Resources.Increase) { var settingValue = x.Value.GetAsInteger("SettingValue"); if (string.IsNullOrEmpty(setting.StringValue)) { setting.IntegerValue = settingValue; } else { setting.IntegerValue = setting.IntegerValue + settingValue; } } else if (updateType == Resources.Decrease) { var settingValue = x.Value.GetAsInteger("SettingValue"); if (string.IsNullOrEmpty(setting.StringValue)) { setting.IntegerValue = settingValue; } else { setting.IntegerValue = setting.IntegerValue - settingValue; } } else if (updateType == "Multiply") { if (string.IsNullOrEmpty(setting.StringValue)) { setting.DecimalValue = 0; } else { setting.DecimalValue = setting.DecimalValue * x.Value.GetAsDecimal("SettingValue"); } } else if (updateType == "Toggle") { var settingValue = x.Value.GetAsString("SettingValue"); var parts = settingValue.Split(','); if (string.IsNullOrEmpty(setting.StringValue)) { setting.StringValue = parts[0]; } else { for (var i = 0; i < parts.Length; i++) { if (parts[i] == setting.StringValue) { setting.StringValue = (i + 1) < parts.Length ? parts[i + 1] : parts[0]; break; } } } } else { var settingValue = x.Value.GetAsString("SettingValue"); setting.StringValue = settingValue; } if (!isLocal) { AppServices.SettingService.SaveChanges(); } } } if (x.Value.Action.ActionType == "RefreshCache") { MethodQueue.Queue("ResetCache", ResetCache); } if (x.Value.Action.ActionType == "SendMessage") { AppServices.MessagingService.SendMessage("ActionMessage", x.Value.GetAsString("Command")); } if (x.Value.Action.ActionType == "SendEmail") { EMailService.SendEMailAsync(x.Value.GetAsString("SMTPServer"), x.Value.GetAsString("SMTPUser"), x.Value.GetAsString("SMTPPassword"), x.Value.GetAsInteger("SMTPPort"), x.Value.GetAsString("ToEMailAddress"), x.Value.GetAsString("FromEMailAddress"), x.Value.GetAsString("Subject"), x.Value.GetAsString("EMailMessage"), x.Value.GetAsString("FileName"), x.Value.GetAsBoolean("DeleteFile"), x.Value.GetAsBoolean("BypassSslErrors")); } if (x.Value.Action.ActionType == "ExecuteTicketEvent") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var operationName = x.Value.GetAsString("TicketOperation"); if (operationName == Resources.Refresh) { EventServiceFactory.EventService.PublishEvent(EventTopicNames.DisplayTicketView); } if (operationName == Resources.Close) { ticket.PublishEvent(EventTopicNames.PaymentSubmitted); } } } if (x.Value.Action.ActionType == "UpdateTicketVat") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var vatTemplateName = x.Value.GetAsString("VatTemplate"); var vatTemplate = AppServices.MainDataContext.VatTemplates.FirstOrDefault(y => y.Name == vatTemplateName); if (vatTemplate != null) { ticket.UpdateVat(vatTemplate); TicketViewModel.RecalculateTicket(ticket); EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } } } if (x.Value.Action.ActionType == "UpdateTicketTaxService") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var taxServiceTemplateName = x.Value.GetAsString("TaxServiceTemplate"); var taxServiceTemplate = AppServices.MainDataContext.TaxServiceTemplates.FirstOrDefault( y => y.Name == taxServiceTemplateName); if (taxServiceTemplate != null) { var amount = x.Value.GetAsDecimal("Amount"); ticket.AddTaxService(taxServiceTemplate.Id, taxServiceTemplate.CalculationMethod, amount); TicketViewModel.RecalculateTicket(ticket); } } } if (x.Value.Action.ActionType == "RegenerateTicketVat") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { TicketViewModel.RegenerateVatRates(ticket); TicketViewModel.RecalculateTicket(ticket); EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } } if (x.Value.Action.ActionType == "AddTicketDiscount") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var percentValue = x.Value.GetAsDecimal("DiscountPercentage"); ticket.AddTicketDiscount(DiscountType.Percent, percentValue, AppServices.CurrentLoggedInUser.Id); TicketViewModel.RecalculateTicket(ticket); } } if (x.Value.Action.ActionType == "AddTicketItem") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var menuItemName = x.Value.GetAsString("MenuItemName"); var menuItem = AppServices.DataAccessService.GetMenuItemByName(menuItemName); var portionName = x.Value.GetAsString("PortionName"); var quantity = x.Value.GetAsDecimal("Quantity"); var gifted = x.Value.GetAsBoolean("Gift"); var giftReason = x.Value.GetAsString("GiftReason"); var tag = x.Value.GetAsString("Tag"); var departmentId = AppServices.CurrentTerminal.DepartmentId > 0 ? AppServices.MainDataContext.SelectedDepartment.Id : ticket.DepartmentId; var ti = ticket.AddTicketItem(AppServices.CurrentLoggedInUser.Id, departmentId, menuItem, portionName, AppServices.MainDataContext.SelectedDepartment.PriceTag, ""); ti.Quantity = quantity; ti.Gifted = gifted; if (gifted && !string.IsNullOrEmpty(giftReason)) { var reason = Dao.SingleWithCache <Reason>(u => u.Name == giftReason); if (reason != null) { ti.ReasonId = reason.Id; } } else { ti.ReasonId = 0; } ti.Tag = tag; TicketViewModel.RecalculateTicket(ticket); EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } } if (x.Value.Action.ActionType == "VoidTicketItems") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var menuItemName = x.Value.GetAsString("MenuItemName"); var tag = x.Value.GetAsString("Tag"); if (!string.IsNullOrEmpty(menuItemName) && !string.IsNullOrEmpty(tag)) { var lines = ticket.TicketItems.Where(y => !y.Voided && (string.IsNullOrEmpty(menuItemName) || y.MenuItemName.Contains(menuItemName)) && (y.Tag.Contains(tag) || string.IsNullOrEmpty(tag))).ToList(); lines.ForEach(y => ticket.VoidItem(y, 0, AppServices.CurrentLoggedInUser.Id)); TicketViewModel.RecalculateTicket(ticket); EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } } } if (x.Value.Action.ActionType == "UpdateTicketTag") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); if (ticket != null) { var tagName = x.Value.GetAsString("TagName"); var tagValue = x.Value.GetAsString("TagValue"); if (tagValue.Contains(",")) { var ctag = ticket.GetTagValue(tagName); if (!string.IsNullOrEmpty(ctag)) { var nextTag = tagValue.Split(',').SkipWhile(y => y != ctag).Skip(1).FirstOrDefault(); if (string.IsNullOrEmpty(nextTag)) { nextTag = tagValue.Split(',')[0]; } tagValue = nextTag; } } ticket.SetTagValue(tagName, tagValue); var tagData = new TicketTagData { TagName = tagName, TagValue = tagValue }; tagData.PublishEvent(EventTopicNames.TagSelectedForSelectedTicket); } } if (x.Value.Action.ActionType == "UpdatePriceTag") { using (var workspace = WorkspaceFactory.Create()) { var priceTag = x.Value.GetAsString("PriceTag"); var departmentName = x.Value.GetAsString("DepartmentName"); var department = workspace.Single <Department>(y => y.Name == departmentName); if (department != null) { department.PriceTag = priceTag; workspace.CommitChanges(); MethodQueue.Queue("ResetCache", ResetCache); } } } if (x.Value.Action.ActionType == "ExecutePrintJob") { var ticket = x.Value.GetDataValue <Ticket>("Ticket"); var pjName = x.Value.GetAsString("PrintJobName"); var ticketItemTag = x.Value.GetAsString("TicketItemTag"); if (!string.IsNullOrEmpty(pjName)) { var j = AppServices.CurrentTerminal.PrintJobs.SingleOrDefault(y => y.Name == pjName); if (j != null) { if (ticket != null) { AppServices.MainDataContext.UpdateTicketNumber(ticket); if (j.LocksTicket) { ticket.RequestLock(); } var clonedTicket = ObjectCloner.Clone(ticket); clonedTicket.CopyPaidItemsCache(ticket); if (!string.IsNullOrEmpty(ticketItemTag)) { clonedTicket.TicketItems = clonedTicket.TicketItems.Where(y => !string.IsNullOrEmpty(y.Tag) && y.Tag.ToLower().Contains(ticketItemTag.Trim().ToLower())).ToList(); } AppServices.PrintService.ManualPrintTicket(clonedTicket, j); } else { AppServices.PrintService.ExecutePrintJob(j); } } } } }); }
public TicketTagButton(TicketTagGroup ticketTagGroup, TicketViewModel ticket) { Model = ticketTagGroup; Caption = Model.Name; _ticket = ticket; }
private void SaveTicketIfNew() { if ((SelectedTicket.Id == 0 || SelectedTicket.Items.Any(x => x.Model.Id == 0)) && SelectedTicket.Items.Count > 0) { var result = AppServices.MainDataContext.CloseTicket(); AppServices.MainDataContext.OpenTicket(result.TicketId); _selectedTicket = null; } }
public TicketListViewModel() { _timer = new Timer(OnTimer, null, Timeout.Infinite, 1000); _selectedTicketItems = new ObservableCollection<TicketItemViewModel>(); PrintJobCommand = new CaptionCommand<PrintJob>(Resources.Print, OnPrintJobExecute, CanExecutePrintJob); AddMenuItemCommand = new DelegateCommand<ScreenMenuItemData>(OnAddMenuItemCommandExecute); CloseTicketCommand = new CaptionCommand<string>(Resources.CloseTicket_r, OnCloseTicketExecute, CanCloseTicket); OpenTicketCommand = new DelegateCommand<int?>(OnOpenTicketExecute); MakePaymentCommand = new CaptionCommand<string>(Resources.GetPayment, OnMakePaymentExecute, CanMakePayment); MakeCashPaymentCommand = new CaptionCommand<string>(Resources.CashPayment_r, OnMakeCashPaymentExecute, CanMakeFastPayment); MakeCreditCardPaymentCommand = new CaptionCommand<string>(Resources.CreditCard_r, OnMakeCreditCardPaymentExecute, CanMakeFastPayment); MakeTicketPaymentCommand = new CaptionCommand<string>(Resources.Voucher_r, OnMakeTicketPaymentExecute, CanMakeFastPayment); SelectTableCommand = new CaptionCommand<string>(Resources.SelectTable, OnSelectTableExecute, CanSelectTable); SelectCustomerCommand = new CaptionCommand<string>(Resources.SelectCustomer, OnSelectCustomerExecute, CanSelectCustomer); ShowAllOpenTickets = new CaptionCommand<string>(Resources.AllTickets_r, OnShowAllOpenTickets); NewTicketCommand = new CaptionCommand<string>(Resources.Ticket, OnCreateNewTicket,CanCreateNewTicket); FilterOpenTicketsCommand = new DelegateCommand<TicketTagFilterViewModel>(OnFilterOpenTicketsExecute); IncQuantityCommand = new CaptionCommand<string>("+", OnIncQuantityCommand, CanIncQuantity); DecQuantityCommand = new CaptionCommand<string>("-", OnDecQuantityCommand, CanDecQuantity); IncSelectionQuantityCommand = new CaptionCommand<string>("(+)", OnIncSelectionQuantityCommand, CanIncSelectionQuantity); DecSelectionQuantityCommand = new CaptionCommand<string>("(-)", OnDecSelectionQuantityCommand, CanDecSelectionQuantity); ShowVoidReasonsCommand = new CaptionCommand<string>(Resources.Void, OnShowVoidReasonsExecuted, CanVoidSelectedItems); ShowGiftReasonsCommand = new CaptionCommand<string>(Resources.Gift, OnShowGiftReasonsExecuted, CanGiftSelectedItems); ShowTicketTagsCommand = new CaptionCommand<TicketTagGroup>(Resources.Tag, OnShowTicketsTagExecute, CanExecuteShowTicketTags); CancelItemCommand = new CaptionCommand<string>(Resources.Cancel, OnCancelItemCommand, CanCancelSelectedItems); MoveTicketItemsCommand = new CaptionCommand<string>(Resources.MoveTicketLine, OnMoveTicketItems, CanMoveTicketItems); ShowExtraPropertyEditorCommand = new CaptionCommand<string>(Resources.ExtraModifier, OnShowExtraProperty, CanShowExtraProperty); EditTicketNoteCommand = new CaptionCommand<string>(Resources.TicketNote, OnEditTicketNote, CanEditTicketNote); RemoveTicketLockCommand = new CaptionCommand<string>(Resources.ReleaseLock, OnRemoveTicketLock, CanRemoveTicketLock); ChangePriceCommand = new CaptionCommand<string>(Resources.ChangePrice, OnChangePrice, CanChangePrice); EventServiceFactory.EventService.GetEvent<GenericEvent<LocationData>>().Subscribe( x => { if (x.Topic == EventTopicNames.LocationSelectedForTicket) { if (SelectedTicket != null) { var oldLocationName = SelectedTicket.Location; var ticketsMerged = x.Value.TicketId > 0 && x.Value.TicketId != SelectedTicket.Id; // TicketViewModel.AssignTableToSelectedTicket(x.Value.LocationId); CloseTicket(); if (!AppServices.CurrentTerminal.AutoLogout) EventServiceFactory.EventService.PublishEvent(EventTopicNames.ActivateTicketView); if (!string.IsNullOrEmpty(oldLocationName) || ticketsMerged) if (ticketsMerged && !string.IsNullOrEmpty(oldLocationName)) InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.TablesMerged_f, oldLocationName, x.Value.Caption)); else if (ticketsMerged) InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.TicketMergedToTable_f, x.Value.Caption)); else if (oldLocationName != x.Value.LocationName) InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.TicketMovedToTable_f, oldLocationName, x.Value.Caption)); } else { if (x.Value.TicketId == 0) { TicketViewModel.CreateNewTicket(); // TicketViewModel.AssignTableToSelectedTicket(x.Value.LocationId); } else { AppServices.MainDataContext.OpenTicket(x.Value.TicketId); } EventServiceFactory.EventService.PublishEvent(EventTopicNames.DisplayTicketView); } } } ); EventServiceFactory.EventService.GetEvent<GenericEvent<WorkPeriod>>().Subscribe( x => { if (x.Topic == EventTopicNames.WorkPeriodStatusChanged) { RaisePropertyChanged("CanChangeDepartment"); } }); EventServiceFactory.EventService.GetEvent<GenericEvent<TicketItemViewModel>>().Subscribe( x => { if (SelectedTicket != null && x.Topic == EventTopicNames.SelectedItemsChanged) { LastSelectedTicketItem = x.Value.Selected ? x.Value : null; foreach (var item in SelectedTicket.SelectedItems) { item.IsLastSelected = item == LastSelectedTicketItem; } SelectedTicket.PublishEvent(EventTopicNames.SelectedItemsChanged); } }); EventServiceFactory.EventService.GetEvent<GenericEvent<TicketTagData>>().Subscribe( x => { if (x.Topic == EventTopicNames.TagSelectedForSelectedTicket) { if (x.Value.Action == 1 && CanCloseTicket("")) CloseTicketCommand.Execute(""); if (x.Value.Action == 2 && CanMakePayment("")) MakePaymentCommand.Execute(""); else { RefreshVisuals(); } } }); EventServiceFactory.EventService.GetEvent<GenericEvent<TicketViewModel>>().Subscribe( x => { if (x.Topic == EventTopicNames.SelectedItemsChanged) { _selectedTicketItems.Clear(); _selectedTicketItems.AddRange(x.Value.SelectedItems); if (x.Value.SelectedItems.Count == 0) LastSelectedTicketItem = null; RaisePropertyChanged("IsItemsSelected"); RaisePropertyChanged("IsNothingSelected"); RaisePropertyChanged("IsNothingSelectedAndTicketLocked"); RaisePropertyChanged("IsCustomerButtonVisible"); RaisePropertyChanged("IsItemsSelectedAndUnlocked"); RaisePropertyChanged("IsItemsSelectedAndLocked"); RaisePropertyChanged("IsTicketSelected"); } }); EventServiceFactory.EventService.GetEvent<GenericEvent<Customer>>().Subscribe( x => { if (x.Topic == EventTopicNames.CustomerSelectedForTicket) { if (AppServices.MainDataContext.SelectedTicket == null) TicketViewModel.CreateNewTicket(); AppServices.MainDataContext.AssignCustomerToSelectedTicket(x.Value); var lastOrder = Dao.Last<Ticket>(y => y.CustomerId == x.Value.Id); var lastOderDayCount = lastOrder != null ? Convert.ToInt32(new TimeSpan(DateTime.Now.Ticks - lastOrder.Date.Ticks).TotalDays) : -1; var lastOderTotal = lastOrder != null ? lastOrder.TotalAmount : -1; RuleExecutor.NotifyEvent(RuleEventNames.CustomerSelectedForTicket, new { Ticket = AppServices.MainDataContext.SelectedTicket, CustomerId = x.Value.Id, CustomerName = x.Value.Name, x.Value.PhoneNumber, CustomerNote = x.Value.Note, // CustomerGroupCode = x.Value.GroupCode, LastOrderTotal = lastOderTotal, LastOrderDayCount = lastOderDayCount }); //if (!string.IsNullOrEmpty(SelectedTicket.CustomerName) && SelectedTicket.Items.Count > 0) // CloseTicket(); //else { RefreshVisuals(); SelectedTicketView = SingleTicketView; } } if (x.Topic == EventTopicNames.PaymentRequestedForTicket) { AppServices.MainDataContext.AssignCustomerToSelectedTicket(x.Value); if (!string.IsNullOrEmpty(SelectedTicket.CustomerName) && SelectedTicket.Items.Count > 0) MakePaymentCommand.Execute(""); else { RefreshVisuals(); SelectedTicketView = SingleTicketView; } } }); EventServiceFactory.EventService.GetEvent<GenericEvent<Ticket>>().Subscribe( x => { _selectedTicket = null; if (x.Topic == EventTopicNames.PaymentSubmitted) { CloseTicket(); } }); EventServiceFactory.EventService.GetEvent<GenericEvent<EventAggregator>>().Subscribe( x => { if (SelectedDepartment == null) UpdateSelectedDepartment(AppServices.CurrentLoggedInUser.UserRole.DepartmentId); if (x.Topic == EventTopicNames.ActivateTicketView) { UpdateSelectedTicketView(); DisplayTickets(); } if (x.Topic == EventTopicNames.DisplayTicketView) { UpdateSelectedTicketView(); RefreshVisuals(); } if (x.Topic == EventTopicNames.RefreshSelectedTicket) { _selectedTicket = null; RefreshVisuals(); SelectedTicketView = SingleTicketView; } }); EventServiceFactory.EventService.GetEvent<GenericEvent<Message>>().Subscribe( x => { if (AppServices.ActiveAppScreen == AppScreens.TicketList && x.Topic == EventTopicNames.MessageReceivedEvent && x.Value.Command == Messages.TicketRefreshMessage) { RefreshOpenTickets(); RefreshVisuals(); } }); EventServiceFactory.EventService.GetEvent<GenericEvent<PopupData>>().Subscribe( x => { if (x.Value.EventMessage == "SelectCustomer") { var dep = AppServices.MainDataContext.Departments.FirstOrDefault(y => y.IsTakeAway); if (dep != null) { UpdateSelectedDepartment(dep.Id); SelectedTicketView = OpenTicketListView; } if (SelectedDepartment == null) SelectedDepartment = AppServices.MainDataContext.Departments.FirstOrDefault(); RefreshVisuals(); } }); EventServiceFactory.EventService.GetEvent<GenericEvent<CreditCardProcessingResult>>().Subscribe(OnProcessCreditCard); }
private void OnCloseTicketExecute(string obj) { if (SelectedTicketItem != null && !SelectedTicketItem.IsLocked) { var unselectedItem = AppServices.DataAccessService.GetUnselectedItem(SelectedTicketItem.Model); if (unselectedItem != null) { InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.SelectionRequired_f, unselectedItem.Name)); return; } } if (SelectedTicket.Items.Count > 0 && SelectedTicket.Model.GetRemainingAmount() == 0) { var message = SelectedTicket.GetPrintError(); if (!string.IsNullOrEmpty(message)) { SelectedTicket.ClearSelectedItems(); RefreshVisuals(); InteractionService.UserIntraction.GiveFeedback(message); return; } } SelectedTicket.ClearSelectedItems(); var result = AppServices.MainDataContext.CloseTicket(); if (!string.IsNullOrEmpty(result.ErrorMessage)) { InteractionService.UserIntraction.GiveFeedback(result.ErrorMessage); } else { RuleExecutor.NotifyEvent(RuleEventNames.TicketClosed, new { Ticket = _selectedTicket.Model }); } _selectedTicket = null; _selectedTicketItems.Clear(); if (AppServices.CurrentTerminal.AutoLogout) { AppServices.LogoutUser(false); AppServices.CurrentLoggedInUser.PublishEvent(EventTopicNames.UserLoggedOut); } else { DisplayTickets(); } AppServices.MessagingService.SendMessage(Messages.TicketRefreshMessage, result.TicketId.ToString()); }
private void OnOpenTicketExecute(int? id) { _selectedTicket = null; _selectedTicketItems.Clear(); AppServices.MainDataContext.OpenTicket(id.GetValueOrDefault(0)); SelectedTicketView = SingleTicketView; RefreshVisuals(); SelectedTicket.ClearSelectedItems(); SelectedTicket.PublishEvent(EventTopicNames.SelectedTicketChanged); }
public void Prepare() { if (SelectedTicket == null) { SelectedTicket = new TicketViewModel(AppServices.MainDataContext.SelectedTicket, AppServices.MainDataContext.SelectedDepartment.IsFastFood); TicketRemainingValue = AppServices.MainDataContext.SelectedTicket.GetRemainingAmount(); PrepareMergedItems(); RefreshValues(); LastTenderedAmount = PaymentAmount; CreateButtons(); OnSetValue(""); if (CreditCardProcessingService.ForcePayment(SelectedTicket.Id)) { TenderedAmount = TicketRemainingValue.ToString("#,#0.00"); SubmitPayment(PaymentType.CreditCard); } } }
private void SetSelectedTicket(TicketViewModel ticketViewModel) { SelectedTicket = ticketViewModel; SelectedItem = SelectedTicket.SelectedItems.Count() == 1 ? SelectedTicket.SelectedItems[0] : null; RaisePropertyChanged("SelectedTicket"); RaisePropertyChanged("SelectedItem"); RaisePropertyChanged("IsTicketNoteEditorVisible"); RaisePropertyChanged("IsExtraPropertyEditorVisible"); RaisePropertyChanged("IsFreeTagEditorVisible"); RaisePropertyChanged("IsPortionsVisible"); RaisePropertyChanged("IsRemoveModifierButtonVisible"); }
private void ResetValues(TicketViewModel selectedTicket) { SelectedTicket = null; SelectedItem = null; SelectedItemPortions.Clear(); SelectedItemPropertyGroups.Clear(); SelectedItemGroupedPropertyItems.Clear(); Reasons.Clear(); TicketTags.Clear(); _showExtraPropertyEditor = false; _showTicketNoteEditor = false; _showFreeTagEditor = false; _removeModifier = false; SetSelectedTicket(selectedTicket); }
public bool ShouldDisplay(TicketViewModel value) { ResetValues(value); if (SelectedItem == null || SelectedItem.Model.Locked) return false; if (SelectedTicket != null && !SelectedItem.Model.Voided && !SelectedItem.Model.Locked) { var id = SelectedItem.Model.MenuItemId; var mi = AppServices.DataAccessService.GetMenuItem(id); if (SelectedItem.Model.PortionCount > 1) SelectedItemPortions.AddRange(mi.Portions); SelectedItemPropertyGroups.AddRange(mi.PropertyGroups.Where(x => string.IsNullOrEmpty(x.GroupTag))); SelectedItemGroupedPropertyItems.AddRange(mi.PropertyGroups.Where(x => !string.IsNullOrEmpty(x.GroupTag) && x.Properties.Count > 1) .GroupBy(x => x.GroupTag) .Select(x => new MenuItemGroupedPropertyViewModel(SelectedItem, x))); RaisePropertyChanged("IsPortionsVisible"); } return SelectedItemPortions.Count > 1 || SelectedItemPropertyGroups.Count > 0 || SelectedItemGroupedPropertyItems.Count > 0; }
public TicketTagButton(TicketTagGroup ticketTagGroup, TicketViewModel ticket) { Model = ticketTagGroup; Caption = Model.Name; _ticket = ticket; }