Exemplo n.º 1
0
        public static void Valid(this ProductEntry productEntry)
        {
            if (productEntry == null)
            {
                throw new ArgumentException($"Entrada de produto não pode estar nula ou vazia.");
            }

            if (productEntry.Supplier == null)
            {
                throw new ArgumentException($"Entrada de produto sem fornecedor.");
            }

            if (productEntry.Product == null)
            {
                throw new ArgumentException($"Entrada de produto sem produto.");
            }
        }
Exemplo n.º 2
0
        public static IList <ProdutEntryDescriptor> GetProductEntriesDescriptor(this ProductEntry productEntry)
        {
            var list = new List <ProdutEntryDescriptor>();

            productEntry.Valid();

            foreach (var item in productEntry.ProductEntryItems)
            {
                var descriptor = new ProdutEntryDescriptor
                {
                    Date                 = productEntry.Date,
                    Supplier             = productEntry.Supplier.Name,
                    ProductName          = productEntry.Product.Description,
                    ProductColor         = item.Variation.Color,
                    ProductGender        = item.Variation.Gender,
                    ProductSize          = item.Variation.Size,
                    ProductQuantity      = item.Variation.Quantity,
                    ProductEntryQuantity = item.Quantity,
                };
                list.Add(descriptor);
            }
            return(list);
        }