Пример #1
0
        public ValidationResponse <Order> GetById(Guid id)
        {
            Order order = _orderRepository.GetById(id);

            if (order == null)
            {
                string message = $"Order with id {id} not found.";
                _logger.LogWarning(message);

                return(new ValidationResponse <Order>(ValidationStatus.NotFound, message));
            }

            return(new ValidationResponse <Order>(order, ValidationStatus.Ok));
        }
Пример #2
0
        public ValidationResponse <Product> GetById(Guid id)
        {
            Product product = _productRepository.GetById(id);

            if (product == null)
            {
                string message = $"Product with id {id} not found.";
                _logger.LogWarning(message);

                return(new ValidationResponse <Product>(ValidationStatus.NotFound, message));
            }

            return(new ValidationResponse <Product>(product, ValidationStatus.Ok));
        }
Пример #3
0
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     if (!context.ModelState.IsValid)
     {
         context.Result = new BadRequestObjectResult(context.ModelState);
         _logger.LogWarning("Model is invalid: " + JsonConvert.SerializeObject(context.Result));
     }
 }
Пример #4
0
        public ValidationResponse <Category> GetById(Guid id)
        {
            Category category = _categoryRepository.GetById(id);

            if (category == null)
            {
                string message = $"Category with id {id} not found.";
                _logger.LogWarning(message);

                return(new ValidationResponse <Category>(ValidationStatus.NotFound, message));
            }

            return(new ValidationResponse <Category>(category, ValidationStatus.Ok));
        }