Пример #1
0
 public MenuItemPropertyViewModel(MenuItemProperty model)
 {
     Model = model;
     if (string.IsNullOrEmpty(model.Name))
         model.Name = string.Format("[{0}]", Resources.NewProperty);
     UpdateMenuItem(model.MenuItemId);
 }
Пример #2
0
        public MenuItemProperty AddProperty(string name, decimal price, string defaultCurrency)
        {
            var prp = new MenuItemProperty {
                Name = name, Price = new Price(price, defaultCurrency)
            };

            Properties.Add(prp);
            return(prp);
        }
        public void UpdateNextProperty(MenuItemProperty current)
        {
            CurrentProperty = current;
            if (CurrentProperty != null && CurrentProperty.Name.ToLower() == "x")
                CurrentProperty = null;
            NextProperty = MenuItemPropertyGroup.Properties.First();
            var selected = _selectedItem.Properties.FirstOrDefault(x => x.Model.PropertyGroupId == MenuItemPropertyGroup.Id);
            var selectedPropertyName = selected != null ? selected.Model.Name : "";

            if (!string.IsNullOrEmpty(selectedPropertyName))
            {
                CurrentProperty = MenuItemPropertyGroup.Properties.FirstOrDefault(x => x.Name == selectedPropertyName);
                var nProp = MenuItemPropertyGroup.Properties.SkipWhile(x => x.Name != selectedPropertyName).Skip(1).FirstOrDefault();
                if (nProp != null) NextProperty = nProp;
            }
            Name = CurrentProperty != null ? CurrentProperty.Name : MenuItemPropertyGroup.Name;
        }
Пример #4
0
 public MenuItemPropertyViewModel(MenuItemProperty model)
 {
     Model = model;
 }
Пример #5
0
 public MenuItemProperty AddProperty(string name, decimal price, string defaultCurrency)
 {
     var prp = new MenuItemProperty { Name = name, Price = new Price(price, defaultCurrency) };
     Properties.Add(prp);
     return prp;
 }
        private void OnPropertySelected(MenuItemProperty obj)
        {
            var mig = SelectedItemPropertyGroups.FirstOrDefault(propertyGroup => propertyGroup.Properties.Contains(obj));
            Debug.Assert(mig != null);
            if (_removeModifier)
            {
                if (mig.ForceValue && SelectedItem.Properties.Count(x => x.Model.PropertyGroupId == mig.Id) < 2)
                    InteractionService.UserIntraction.GiveFeedback(string.Format(Resources.SelectionRequired_f, mig.Name));
                else
                    SelectedItem.RemoveProperty(mig, obj);
            }
            else SelectedItem.ToggleProperty(mig, obj);

            SelectedTicket.RefreshVisuals();
            SelectedTicket.RecalculateTicket();
            if (_removeModifier)
                OnRemoveModifier("");
            RaisePropertyChanged("IsRemoveModifierButtonVisible");
        }
Пример #7
0
 public void RemoveProperty(MenuItemPropertyGroup mig, MenuItemProperty menuItemProperty)
 {
     var p = Model.Properties.Where(x => x.PropertyGroupId == mig.Id && x.Name == menuItemProperty.Name && (x.VatAmount + x.PropertyPrice.Amount) == menuItemProperty.Price.Amount).FirstOrDefault();
     if (p != null)
     {
         Model.Properties.Remove(p);
     }
     RefreshProperties();
     RaisePropertyChanged("Properties");
     RaisePropertyChanged("TotalPrice");
     RaisePropertyChanged("Quantity");
 }
Пример #8
0
 public TicketItemProperty ToggleProperty(MenuItemPropertyGroup group, MenuItemProperty menuItemProperty)
 {
     var ti = _model.ToggleProperty(group, menuItemProperty);
     if (ti != null)
     {
         RuleExecutor.NotifyEvent(RuleEventNames.ModifierSelected,
                                  new
                                      {
                                          Ticket = AppServices.MainDataContext.SelectedTicket,
                                          TicketItem = Model,
                                          TicketTag = AppServices.MainDataContext.SelectedTicket.Tag,
                                          MenuItemName = _model.MenuItemName,
                                          ModifierGroupName = group.Name,
                                          ModifierName = menuItemProperty.Name,
                                          ModifierPrice = ti.PropertyPrice.Amount + ti.VatAmount,
                                          ModifierQuantity = ti.Quantity,
                                          IsRemoved = !_model.Properties.Contains(ti),
                                          IsPriceAddedToParentPrice = ti.CalculateWithParentPrice,
                                          TotalPropertyCount = Model.Properties.Count,
                                          TotalModifierQuantity = Model.Properties.Where(x => x.PropertyGroupId == group.Id).Sum(x => x.Quantity),
                                          TotalModifierPrice = Model.Properties.Where(x => x.PropertyGroupId == group.Id).Sum(x => x.PropertyPrice.Amount + x.VatAmount)
                                      });
     }
     RefreshProperties();
     RaisePropertyChanged("Properties");
     RaisePropertyChanged("TotalPrice");
     RaisePropertyChanged("Quantity");
     return ti;
 }
Пример #9
0
 private TicketItemProperty FindProperty(MenuItemProperty property)
 {
     return Properties.FirstOrDefault(x => x.Name == property.Name && (x.PropertyPrice.Amount + x.VatAmount) == property.Price.Amount);
 }
Пример #10
0
        public TicketItemProperty ToggleProperty(MenuItemPropertyGroup group, MenuItemProperty property)
        {
            if (property.Name.ToLower() == "x")
            {
                var groupItems = Properties.Where(x => x.PropertyGroupId == group.Id).ToList();
                foreach (var tip in groupItems) Properties.Remove(tip);
                if (group.MultipleSelection) Quantity = 1;
                return null;
            }

            var ti = FindProperty(property);
            if (ti == null)
            {
                ti = new TicketItemProperty
                        {
                            Name = property.Name,
                            PropertyPrice = new Price { Amount = property.Price.Amount, CurrencyCode = property.Price.CurrencyCode },
                            PropertyGroupId = group.Id,
                            MenuItemId = property.MenuItemId,
                            CalculateWithParentPrice = group.CalculateWithParentPrice,
                            PortionName = PortionName,
                            Quantity = group.MultipleSelection ? 0 : 1
                        };

                if (VatIncluded && VatRate > 0)
                {
                    ti.PropertyPrice.Amount = ti.PropertyPrice.Amount / ((100 + VatRate) / 100);
                    ti.PropertyPrice.Amount = decimal.Round(ti.PropertyPrice.Amount, 2);
                    ti.VatAmount = property.Price.Amount - ti.PropertyPrice.Amount;
                }
                else if (VatRate > 0) ti.VatAmount = (property.Price.Amount * VatRate) / 100;
                else ti.VatAmount = 0;
            }
            if (group.SingleSelection || !string.IsNullOrEmpty(group.GroupTag))
            {
                var tip = Properties.FirstOrDefault(x => x.PropertyGroupId == group.Id);
                if (tip != null)
                {
                    Properties.Insert(Properties.IndexOf(tip), ti);
                    Properties.Remove(tip);
                }
            }
            else if (group.MultipleSelection)
            {
                ti.Quantity++;
            }
            else if (!group.MultipleSelection && Properties.Contains(ti))
            {
                Properties.Remove(ti);
                _lastSelectedProperty = ti;
                return ti;
            }

            if (!Properties.Contains(ti)) Properties.Add(ti);

            _lastSelectedProperty = ti;
            return ti;
        }