Esempio n. 1
0
        public IHttpActionResult Get([DataSourceRequest] DataSourceRequest request, int SaleId = 0)
        {
            var list          = _serviceSale.ListSaleLineItems(SaleId);
            var sliWViewModel = new List <SaleLineItemViewModel>();

            foreach (var sli in list)
            {
                var product = _serviceSale.FetchProduct(sli.ProductId);
                var vm      = new SaleLineItemViewModel {
                    UnitPrice = product.UnitPrice, Subtotal = sli.Amount * sli.Qty, SaleLineItemId = sli.Id, saleId = sli.SaleId, Qty = sli.Qty, Amount = sli.Amount, Product = new ProductViewModel {
                        ProductId = product.Id, Name = product.ProductName
                    }
                };
                sliWViewModel.Add(vm);
            }
            return(Ok(sliWViewModel));
        }
Esempio n. 2
0
 public IHttpActionResult Get(int ProductId = 0)
 {
     if (ProductId == 0)
     {
         var list   = _serviceSale.ListProducts();
         var vMList = new List <ProductViewModel>();
         foreach (var product in list)
         {
             var productVM = new ProductViewModel {
                 ProductId = product.Id, Name = product.ProductName, UnitPrice = product.UnitPrice, Description = product.Description
             };
             vMList.Add(productVM);
         }
         return(Ok(vMList));
     }
     else
     {
         var product   = _serviceSale.FetchProduct(ProductId);
         var productVM = new ProductViewModel {
             ProductId = product.Id, Name = product.ProductName, UnitPrice = product.UnitPrice, Description = product.Description
         };
         return(Ok(productVM));
     }
 }