Exemplo n.º 1
0
        public async Task <IActionResult> UpdateCompetidor([FromBody] CompetidorDto competidorDto, int?id)
        {
            _logger?.LogInformation($"{nameof(UpdateCompetidor)}' se ha invocado con id: {id}");
            if (ModelState.IsValid && id.HasValue && id.Value == competidorDto.Id)
            {
                var response = await _competidorSvc.UpdateAsync(competidorDto);

                return(response.ToHttpResponse());
            }

            return(BadRequest(ModelState));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateCompetidor([FromBody] CompetidorDto competidorDto)
        {
            _logger?.LogInformation($"{nameof(CreateCompetidor)}' se ha invocado");
            if (ModelState.IsValid)
            {
                var response = await _competidorSvc.CreateAsync(competidorDto);

                return(Created(new Uri($"{Request.Path}/{response.Data.Id}", UriKind.Relative), response));//return 201 created and its data entity
            }

            return(BadRequest(ModelState));
        }