private async Task <Retorno> Excluir(DiretorDTO command) { if (command.Invalid) { return(new Retorno(false, "Dados Inválidos!", command.Notifications)); } return(await _repository.Excluir(command.Id)); }
private async Task <Retorno> Cadastrar(DiretorDTO command) { command.Validate(); if (command.Invalid) { return(new Retorno(false, "Dados Inválidos!", command.Notifications)); } var Diretor = new Diretor { Nome = command.Nome }; return(await _repository.Cadastrar(Diretor)); }
public async Task <IActionResult> Put([FromBody] DiretorDTO diretor) { try { var retorno = (Retorno)await _rep.Persistir(diretor, ELogin.ATUALIZAR); if (retorno.Sucesso == false) { return(BadRequest(retorno)); } return(Ok(retorno)); } catch (Exception ex) { GerarLog("Erro ao Atualizar o diretor", ex: ex); return(StatusCode(500, ex.ToString())); } }
public async Task <ICommandResult> Persistir(DiretorDTO command, ELogin acoes) { var retorno = new Retorno(); switch (acoes) { case ELogin.CADASTRAR: retorno = await Cadastrar(command); break; case ELogin.ATUALIZAR: retorno = await Atualizar(command); break; case ELogin.EXCLUIR: retorno = await Excluir(command); break; } return(retorno); }