private async Task <Retorno> Excluir(FilmeXatorDTO command)
        {
            if (command.Invalid)
            {
                return(new Retorno(false, "Dados Inválidos!", command.Notifications));
            }

            return(await _repository.Excluir(command.Id));
        }
        private async Task <Retorno> Atualizar(FilmeXatorDTO command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new Retorno(false, "Dados Inválidos!", command.Notifications));
            }

            var filmeXAtor = new FilmeXator
            {
                Id      = command.Id,
                IdAtor  = command.IdAtor,
                IdFilme = command.IdFilme
            };

            return(await _repository.Atualizar(filmeXAtor));
        }
示例#3
0
        public async Task <IActionResult> Delete([FromBody] FilmeXatorDTO filmeXAtor)
        {
            try
            {
                var retorno = (Retorno)await _rep.Persistir(filmeXAtor, 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(FilmeXatorDTO 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);
        }