public async Task <ActionResult <StateOrderViewModel> > GetByIdAsync(int id) { var existingStateOrderViewModel = await _queries.FindByIdAsync(id); if (existingStateOrderViewModel == null) { return(NotFound()); } return(existingStateOrderViewModel); }
public async Task <ActionResult <OrderViewModel> > UpdateRatingOrderAsync(int id, UpdateStateOrderCommand updateStateOrderCommand) { var existingOrderViewModel = await _queries.FindByIdAsync(id); var existingStateOrder = await _stateOrderQueries.FindByIdAsync(updateStateOrderCommand.StateOrderId); if (existingOrderViewModel == null || existingStateOrder == null) { return(NotFound()); } Order order = _mapper.Map <Order>(existingOrderViewModel); _mapper.Map(updateStateOrderCommand, order); await _behavior.UpdateOrderAsync(order); var orderViewModel = await _queries.FindByIdAsync(order.Id); return(orderViewModel); }