public IActionResult PostOrder(Guid customerId, [FromBody] OrderDto orderDto) { ISpecification <Customer> specification = new CustomerByIdSpecification(Identity.Create(customerId)); Customer customer = customerRepository.GetEntity(specification); Order order = orderDto.Execute(mapper.Map <OrderDto, Order>); customer.AddOrder(order); return(Ok()); }
public IActionResult GetCustomer(Guid id) { ISpecification <Customer> specification = new CustomerByIdSpecification(Identity.Create(id)); Customer customer = customerRepository.GetEntity(specification); if (customer == null) { return(NotFound($"Customer with id {id} was not found")); } CustomerDto customerDto = customer.Execute(mapper.Map <Customer, CustomerDto>); return(Ok(customerDto)); }