示例#1
0
        public async Task <ActionResult <Invoice> > Invoice(int id)
        {
            var order = await _orderService.GetOrderById(id);

            var rents = new List <Rent>();

            if (order.OrderRequestItems.Any())
            {
                foreach (var item in order.OrderRequestItems)
                {
                    var r = new Rent {
                        Name = item.Equipment.Name.Trim(), Amount = _helper.CalculateAmount(item)
                    };
                    rents.Add(r);
                }
            }
            var invoice = new Invoice
            {
                Title      = "Invoice for the Rent of Equipment on the " + order.DateCreated.ToLongTimeString(),
                TotalPrice = _helper.CalculateTotalOrderAmount(order),
                Rents      = rents,
                Bonus      = _helper.CalculateTotalOrderBonus(order)
            };

            return(Ok(invoice));
        }