Esempio n. 1
0
        public IActionResult Get(int id, bool includeMaterial = false)
        {
            var product = _flowRepository.GetFlow(id, includeMaterial);

            if (product == null)
            {
                return(NotFound());
            }
            if (includeMaterial)
            {
                var hasMa = Mapper.Map <Flow>(product);
                return(Ok(hasMa));
            }
            var onlyProductResult = Mapper.Map <ProductWithoutMaterialDto>(product);

            return(Ok(onlyProductResult));
            //try
            //{
            //    throw new Exception();
            //    var result = FlowServices.Current.list.FirstOrDefault(x => x.Id == id);

            //    if (result == null)
            //    {
            //        _log.LogInformation($"id为{id}的产品没有被找到");
            //        return NotFound();
            //    }
            //    return Ok(new JsonResult(result));
            //}
            //catch (Exception)
            //{
            //    _log.LogCritical($"{id}异常走起");
            //    return StatusCode(500, "内部错误");
            //}
        }