public IActionResult Get(int orderId) { try { var order = _repository.GetOrderById(orderId); if (order != null) { return(Ok(_mapper.Map <IEnumerable <OrderItem>, IEnumerable <OrderItemViewModel> >(order.Items))); } else { return(NotFound()); } } catch (Exception ex) { return(BadRequest("Sana Error: " + ex.Message)); } }
[HttpGet("{id:int}")]//Expecting integers only public IActionResult Get(int id) { try { var order = _repository.GetOrderById(id); if (order != null) { return(Ok(_mapper.Map <Order, OrderViewModel>(order))); } else { return(NotFound()); } } catch (Exception ex) { return(BadRequest("Error getting Order: " + ex.Message)); } }