public override IActionResult Get(string sortExpression)
        {
            var response = _saleOrderService.GetAll(order => order.Include(or => or.Creator)
                                                    .Include(or => or.Lines)
                                                    .Include(or => or.Status)
                                                    .Include(or => or.Client)
                                                    .ThenInclude(or => or.Person)
                                                    .Include(or => or.Employee)
                                                    .ThenInclude(or => or.Person),
                                                    order => order.Active.Value);

            return(Ok(response));
        }
예제 #2
0
        public ProfitReport GetProfits(int deltaDays)
        {
            return(new ProfitReport
            {
                Incomes = _saleOrderService.GetAll()
                          .Where(s => s.DateOfSale > DateTime.Now.AddDays(-deltaDays))
                          .Select(p => new KeyValuePair <DateTime, decimal>(p.DateOfSale,
                                                                            p.SoldItems.Aggregate <ItemSaleOrder, decimal>(0, (a, b) => {
                    return a + b.SoldPrice * b.SoldQuantity;
                })))
                          .ToList(),

                Expenses = _purchaseOrderService.GetAll()
                           .Where(p => p.DateOfPurchase > DateTime.Now.AddDays(-deltaDays))
                           .Select(p => new KeyValuePair <DateTime, decimal>(p.DateOfPurchase,
                                                                             p.PurchasedItems.Aggregate <ItemPurchaseOrder, decimal>(0, (a, b) => {
                    return a + b.PurchasedPrice * b.PurchasedQuantity;
                })))
                           .ToList()
            });
        }
 public IEnumerable <SaleOrderViewModel> GetSaleOrders()
 {
     return(_saleOrderService.GetAll().Select(s => Mapper.Map <SaleOrderViewModel>(s)));
 }