public ActionResult Get(int id) { ProductDisplayQuery lv_productDisplay = new ProductDisplayQuery { Id = id }; var result = _queryHandler.Handler(lv_productDisplay); if (result != null) { return(Ok(result)); } return(NotFound()); }
public ProductDisplayQuery Handler(ProductDisplayQuery query) { try { Product lv_product = _storeDbContext.Product.Find(query.Id); if (lv_product != null) { _mapper.Map(lv_product, query); } return(query); } catch (Exception e) { throw new Exception($"Cannot find Product #{query.Id} in the store, {e.Message}."); } }