private async Task <Retorno> Excluir(FilmeXGeneroDTO command) { if (command.Invalid) { return(new Retorno(false, "Dados Inválidos!", command.Notifications)); } return(await _repository.Excluir(command.Id)); }
private async Task <Retorno> Atualizar(FilmeXGeneroDTO command) { command.Validate(); if (command.Invalid) { return(new Retorno(false, "Dados Inválidos!", command.Notifications)); } var FilmeXGenero = new FilmeXgenero { Id = command.Id, IdGenero = command.IdGenero, IdFilme = command.IdFilme }; return(await _repository.Atualizar(FilmeXGenero)); }
public async Task <IActionResult> Delete([FromBody] FilmeXGeneroDTO filmeXGenero) { try { var retorno = (Retorno)await _rep.Persistir(filmeXGenero, ELogin.EXCLUIR); if (retorno.Sucesso == false) { return(BadRequest(retorno)); } return(Ok(retorno)); } catch (Exception ex) { GerarLog("Erro ao Excluir o usuário", ex: ex); return(StatusCode(500, ex.ToString())); } }
public async Task <ICommandResult> Persistir(FilmeXGeneroDTO 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); }