Upload data from one action to another

0

I have a Action HttpGet , where this Action gets two parameters, dataInicial , and dataFinal , this generates a report, in the same Action . only I would like to send this data (List) to another screen, where it is already ready for A4 size printing, I would like to know just how to send this data to this other view, I already tried to use return RedirectToAction("RelatorioTotalPorDatadois", vrDb); but did not right.

public ActionResult RelatorioData(DateTime? dataInicio, DateTime? dataFim)
{
    ViewBag.dataInicial = dataInicio;
    ViewBag.dataFinal = dataFim;

    if (dataInicio == null && dataFim == null)
    {
        var vrDb = db.VrDb.Where(v => v.DataSolicitacao >= dataInicio && v.DataSolicitacao <= dataFim).OrderBy(v => v.DataSolicitacao).ToList();
        return View(vrDb);
    }

    else
    {
        var vrDb = db.VrDb.Where(v => v.DataSolicitacao >= dataInicio && v.DataSolicitacao <= dataFim && v.Situacao == Situacao.Finalizado).OrderBy(v => v.DataSolicitacao).ToList();
        var data = dataInicio;
        var dataF = dataFim;

        var tot = db.VrDb.Sum(v => v.Mv.Consumo); //Mostra o Total gasto

        if (tot == 0)
        {
            ViewBag.Total = "0";
        }
        else
        {
            ViewBag.Total = tot;
        }

        var abastecido = db.VrDb.Sum(v => v.Mv.CombustivelAbastecido);
        if (abastecido == 0)
        {
            ViewBag.Abastecido = "0";
        }
        else
        {
            ViewBag.Abastecido = abastecido;
        }

        ViewBag.ListaDb = vrDb;
        return View(vrDb);
        //return RedirectToAction("RelatorioTotalPorDatadois", vrDb);

    }
}

This is the screen of this Action :

ButI'dliketoputabuttononthisscreenwiththePrintoption:Wherethisdatawasloadedontoanotherscreen

    
asked by anonymous 01.08.2018 / 22:46

1 answer

0

To be able to pass objects between Views or have to be:

TempData using keep () and peek () or using Session, because the view only reflects the information that is sent by the action. To pass objects from View to View I only know these options.

    
02.08.2018 / 17:08