예제 #1
0
        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());
        }
예제 #2
0
        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}.");
            }
        }