Example #1
0
        public async Task <ActionResult <OrderRepresentation> > CreateOrder([FromRoute] string customerId, [FromBody] OrderSpecification spec)
        {
            var customer = await this._customers.GetByIdAsync(customerId);

            var order = await this._orders.AddAsync(customer, spec.Description, spec.Date, spec.Amount);

            return(this.Ok(OrderRepresentation.FromEntity(order)));
        }
Example #2
0
        public async Task <ActionResult <IEnumerable <OrderRepresentation> > > FindOrders([FromRoute] string customerId)
        {
            var customer = await this._customers.GetByIdAsync(customerId);

            var orders = customer.Orders;

            return(this.Ok(orders.Select(d => OrderRepresentation.FromEntity(d))));
        }
Example #3
0
        public IActionResult Detail(string id)
        {
            var order = this._orders.GetById(id);

            return(this.View(OrderRepresentation.FromEntity(order)));
        }
Example #4
0
 public IActionResult List()
 {
     return(this.View(this._orders.Items.Select(o => OrderRepresentation.FromEntity(o))));
 }