public async Task <PadraoResponse <Teste> > PutTeste(Teste model) { PadraoResponse <Teste> response = new PadraoResponse <Teste>(); if (model.Id == Guid.Empty) { throw new Exception("O CAMPO Id é obrigatório!"); } Teste modelCadastrado = await _unitOfWork.TesteRepository.GetUm(e => e.Id == model.Id); if (modelCadastrado is null) { throw new Exception("Manda o Id certo bobão!"); } modelCadastrado.Nome = model.Nome; modelCadastrado.AtualizarRegistro(); _unitOfWork.TesteRepository.Atualizar(modelCadastrado); await _unitOfWork.CommitAsync(); response.Data = modelCadastrado; return(response); }
public async Task <PadraoResponse <Teste> > GetTeste(Guid id) { PadraoResponse <Teste> response = new PadraoResponse <Teste>(); Teste modelCadastrado = await _unitOfWork.TesteRepository.GetUm(e => e.Id == id); response.Data = modelCadastrado; return(response); }
public async Task <PadraoResponse <Teste> > PostTeste(Teste model) { PadraoResponse <Teste> response = new PadraoResponse <Teste>(); model.Id = Guid.NewGuid(); model.NovoRegistro(); await _unitOfWork.TesteRepository.Inserir(model); await _unitOfWork.CommitAsync(); _testeServiceBus.PublishTeste(model); response.Data = model; return(response); }
public void OnException(ExceptionContext context) { PadraoResponse <string> responseData = new PadraoResponse <string>() { Mensagem = context.Exception.Message }; HttpStatusCode status = HttpStatusCode.BadRequest; context.ExceptionHandled = true; HttpResponse response = context.HttpContext.Response; response.StatusCode = (int)status; response.ContentType = "application/json"; context.Result = new ObjectResult(responseData); }
public async Task <PadraoResponse <Teste> > DeleteTeste(Guid id) { PadraoResponse <Teste> response = new PadraoResponse <Teste>(); if (id == Guid.Empty) { throw new Exception("O CAMPO Id é obrigatório!"); } Teste modelCadastrado = await _unitOfWork.TesteRepository.GetUm(e => e.Id == id); _unitOfWork.TesteRepository.Deletar(modelCadastrado); await _unitOfWork.CommitAsync(); response.Data = modelCadastrado; return(response); }
public async Task <IActionResult> DeleteTeste(Guid id) { PadraoResponse <Teste> response = await _testeService.DeleteTeste(id); return(Ok(response)); }
public async Task <IActionResult> PutTeste(Teste model) { PadraoResponse <Teste> response = await _testeService.PutTeste(model); return(Ok(response)); }