public IActionResult Create([FromBody] CreateBookDto bookDto)
        {
            if (!ModelState.IsValid)
            {
                return(ValidationProblem(ModelState));
            }

            return(Ok(bookDto));
        }
        public async Task <IActionResult> Create(string name, decimal price)
        {
            var bookDto = new CreateBookDto {
                Name = name, Price = price
            };

            await _bookService.CreateAsync(bookDto);

            return(Ok(bookDto));
        }
        public IActionResult CreateForObjectValidator(string name, decimal price)
        {
            var bookDto = new CreateBookDto {
                Name = name, Price = price
            };

            _objectValidator.Validate(bookDto);

            //var results = _objectValidator.GetErrors(bookDto);

            return(Ok(bookDto));
        }
Beispiel #4
0
        //[DisableValidation]
        //[EnableValidation]
        public virtual async Task CreateAsync(CreateBookDto bookDto)
        {
            await Task.CompletedTask;

            _logger.LogInformation("The {0} has been created.", bookDto.Name);
        }