Exemplo n.º 1
0
        public async Task <string> DevolverLocacao([FromBody] DadosLocacao value)
        {
            var cliente = new tb_ClienteCF();
            var filme   = new tb_FilmeCF();

            if (string.IsNullOrEmpty(value.cpfCliente) || !clienteHelper.IsCpf(value.cpfCliente) || clienteHelper.CPFshorter(value.cpfCliente).Length != 11)
            {
                return("O CPF está invalido ou incorreto");
            }
            else
            {
                cliente = clienteHelper.VerificaCliente(value.cpfCliente, value.nomeCliente, value.idCliente);
                if (cliente == null)
                {
                    return("Cliente não foi encontrado");
                }
            }
            var locacaoPendente = locacaoHelper.VerificaLocacaoPendente(cliente.idCliente);

            if (locacaoPendente == null)
            {
                return("Não há locação pendente para esse cliente");
            }
            locacaoPendente.Item2.dataDevolucao = DateTime.UtcNow;
            await locacaoHelper.DesativarLocacaoAsync(locacaoPendente.Item2);

            filme            = filmeHelper.GetFilme(locacaoPendente.Item2.tb_FilmeCF.idFilme);
            filme.filmeAtivo = true;
            await filmeHelper.SalvarFilmeAsync(filme);

            return("Devolução concluida! Obrigado!");
        }
Exemplo n.º 2
0
        public async Task <string> CadastrarFilmeAsync([FromBody] tb_FilmeCF value)
        {
            if (string.IsNullOrEmpty(value.nomeFilme))
            {
                return("É necessario um nome para registrar o filme");
            }
            var filme = filmeHelper.GetFilme(value.nomeFilme);

            if (filme == null)
            {
                value.filmeAtivo = true;
                await filmeHelper.SalvarFilmeAsync(value);

                return("Concluido");
            }
            else
            {
                return("Esse filme já está cadastrado");
            }
        }