コード例 #1
0
        public IActionResult Get(int id)
        {
            BrandBO      brandBO;
            Brand        brand;
            ObjectResult response;

            try
            {
                _log.LogInformation($"Starting Get( {id} )");

                brandBO = new BrandBO(_loggerFactory, _config);

                brand = brandBO.Get(id);

                if (brand != null)
                {
                    response = Ok(brand);
                }
                else
                {
                    response = NotFound(string.Empty);
                }

                _log.LogInformation($"Finishing Get( {id} )");
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                response = StatusCode(500, ex.Message);
            }

            return(response);
        }
コード例 #2
0
        public IActionResult Get(string name = null)
        {
            BrandBO      brandBO;
            List <Brand> brands;
            ObjectResult response;

            try
            {
                _log.LogInformation("Starting Get()");

                brandBO = new BrandBO(_loggerFactory, _config);
                brands  = brandBO.Get(name);

                response = Ok(brands);

                _log.LogInformation($"Finishing Get() with '{brands.Count}' results");
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                response = StatusCode(500, ex.Message);
            }

            return(response);
        }