Exemple #1
0
        public ActionResult <List <SalesOrderDto> > GetSalesOrders([FromQuery] int?customerId)
        {
            // Query string parameters are allowed here; the name of the parameter defines what the search will be.

            IList <SalesOrder> salesOrders = null;

            if (customerId != null)
            {
                salesOrders = salesOrdersService.ReadSalesOrdersByCustomerId((int)customerId).ToList();
            }
            else
            {
                salesOrders = salesOrdersService.ReadSalesOrders().ToList();
            }

            List <SalesOrderDto> salesOrderDtos = new List <SalesOrderDto>();

            foreach (SalesOrder salesOrder in salesOrders)
            {
                salesOrderDtos.Add(new SalesOrderDto(salesOrder));
            }

            return(salesOrderDtos);
        }