public async Task <IActionResult> PutAsync(int customerId, int id, [FromBody] SaveCustomerOrderResource resource) { var customer = await _customerOrderService.FindCustomerAsync(customerId); if (customer == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var order = _mapper.Map <SaveCustomerOrderResource, Order>(resource); var result = await _customerOrderService.UpdateAsync(id, order); if (!result.Success) { return(BadRequest(result.Message)); } var customerOrderResource = _mapper.Map <Order, SaveCustomerOrderResource>(result.Order); return(Ok(customerOrderResource)); }