public async Task <ActionResult> Post([FromBody] VotacaoDtoCreate votacao) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await _service.Post(votacao); if (result != null) { return(Created(new Uri(Url.Link("GetVotacaoId", new { id = result.Id })), result)); } else { return(BadRequest()); } } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public async Task <VotacaoEntity> Post(VotacaoDtoCreate votacao) { var entity = _mapper.Map <VotacaoEntity>(votacao); return(await _repository.InsertAsync(entity)); }