Ejemplo n.º 1
0
 public void RemoveItems()
 {
     foreach (var item in CommercialItems.ToList())
     {
         CommercialItems.Remove(item);
     }
 }
Ejemplo n.º 2
0
        public CommercialItem AddItem(Items.Item item, int amount)
        {
            Log = string.Format("{0}{1}{2}", Log, "> Add item " + item.PartNumber.ToString(), Environment.NewLine);

            if (CommercialItems == null)
            {
                CommercialItems = new HashSet <CommercialItem>();
            }

            if (!ValidateItemType(item))
            {
                return(null);
            }
            int order         = CommercialItems.Count + 1;
            var commecialItem = new CommercialItem()
            {
                Id              = Guid.NewGuid(),
                ItemGuid        = item.Id,
                Item            = item,
                ItemPartNumber  = item.PartNumber,
                ItemDescription = item.Description,
                UnitPrice       = item.UnitPrice,
                Amount          = amount,
                TransactionType = TransactionType,
                Order           = order
            };

            CommercialItems.Add(commecialItem);

            return(commecialItem);
        }
Ejemplo n.º 3
0
        public void RemoveItem(Guid itemId)
        {
            var item = CommercialItems
                       .Where(Item => Item.ItemGuid == itemId)
                       .FirstOrDefault();

            if (item != null)
            {
                CommercialItems.Remove(item);
            }
        }
Ejemplo n.º 4
0
        public void SortItemsOrder()
        {
            var commecialItems = CommercialItems.OrderBy(item => item.Order)
                                 .ToList();

            int i = 1;

            foreach (var item in commecialItems)
            {
                item.Order = i;
                i++;
            }
        }
Ejemplo n.º 5
0
 public void ReCalculateItems()
 {
     this.SortItemsOrder();
     this.LinesTotal = CommercialItems?.ToList().Sum(i => i.LineTotal) ?? 0;
 }