Inheritance: IEntity, IOrderable
 public MenuItemGroupedPropertyItemViewModel(TicketItemViewModel selectedItem, MenuItemPropertyGroup menuItemPropertyGroup)
 {
     _selectedItem = selectedItem;
     MenuItemPropertyGroup = menuItemPropertyGroup;
     UpdateNextProperty(null);
 }
Example #2
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;
 }
Example #3
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");
 }
 public MenuItemPropertyGroupViewModel(MenuItemPropertyGroup model)
 {
     Model = model;
     Properties = new List<MenuItemPropertyViewModel>(model.Properties.Select(x => new MenuItemPropertyViewModel(x)));
 }
        public IEnumerable<MenuItemProperty> BatchCreateMenuProperties(string[] values, MenuItemPropertyGroup item)
        {
            IList<MenuItemProperty> result = new List<MenuItemProperty>();
             var ds = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
            if (values.Length > 0)
            {
                foreach (var propertyLine in values)
                {

                    var tokens = propertyLine.Split('|');
                    var price = ConvertToDecimal("0.00", ds);
                    var name = tokens[0];
                    if (tokens.Count() > 1)
                    {
                        price = ConvertToDecimal(tokens[1], ds);
                    }
                    result.Add(MenuItem.AddDefaultMenuItemProperty(item, name, price));
                }
            }
            return result;
        }
Example #6
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;
        }
Example #7
0
 public static MenuItemProperty AddDefaultMenuItemProperty(MenuItemPropertyGroup item)
 {
     return item.AddProperty("", 0, LocalSettings.CurrencySymbol);
 }
Example #8
0
 public static MenuItemProperty AddDefaultMenuItemProperty(MenuItemPropertyGroup item, string name, decimal price)
 {
     return item.AddProperty(name, price, LocalSettings.CurrencySymbol);
 }