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))); }
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)))); }
public IActionResult Detail(string id) { var order = this._orders.GetById(id); return(this.View(OrderRepresentation.FromEntity(order))); }
public IActionResult List() { return(this.View(this._orders.Items.Select(o => OrderRepresentation.FromEntity(o)))); }