示例#1
0
        public async Task <IActionResult> PostAsync([FromBody] PostBatch request)
        {
            var prefix = "[PostAsync]";

            _logger.LogInformation($"{prefix} Executing action");

            if (!ModelState.IsValid)
            {
                _logger.LogWarning($"{prefix} Invalid model");
                return(BadRequest(ModelState));
            }

            var entity   = _mapper.Map <PostBatch, BatchDTO>(request);
            var response = await _service.AddAsync(entity);

            _logger.LogInformation($"{prefix} Added batch with id {response.ID}");
            return(Created($"api/batches/{response.ID}", response));
        }