Example #1
0
        public async Task <IActionResult> Extrato([FromRoute] int Id, TransacoesQuery filtros)
        {
            if (!HttpContext.Session.Keys.Any())
            {
                return(RedirectToAction("Index", "Login", new { area = "" }));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                else
                {
                    filtros          = filtros ?? new TransacoesQuery();
                    filtros.PorConta = Id.ToString();
                    TransacoesViewModel vm = new TransacoesViewModel
                    {
                        Filtros = filtros
                    };
                    await vm.GetConta(Id);

                    try
                    {
                        await vm.GetTransacoes();
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = ex;
                    }


                    string nomePessoa = HttpContext.Session.GetString("nome");
                    string genero     = HttpContext.Session.GetString("genero") == "masculino" ? "Sr." : "Sra.";
                    ViewBag.Pessoa = genero + " " + nomePessoa;

                    return(View(vm));
                }
            }
        }