I know my problem is logical and this should start with me, I know, but sometimes a light, not a ready code, but the pointing of a path helps us a lot.
1) I have 6 ComboBox in my View that make the filters for a search.
2) This search should mount a CheckBox's, based on the last filter. It turns out that this assembly of checkbox's, the LINQ that brings the result is my model. Some told me here to pass parameter directly to the Model, it breaks the OO paradigm and I agree. At that moment my problem begins.
3) I'm having a hard time doing this. I fill in the parameters in View and via JQuery I get them. Now how do I distribute it to my model, so that LINQ is executed with these filters being passed in the LINQ or Lambda where. Below my Model.
public static List<MontaArvoreAcao> montaArvoreAcao( )
{
RupturaEntities db = new RupturaEntities();
var monta_arvore = (from rup in db.Ruptura
join ap in db.Apresentacao on rup.Codigo_Apresentacao equals (ap.Codigo_Apresentacao)
join mo in db.Motivo on rup.IDMotivo equals (mo.IDMotivo)
join pdv in db.PDV on rup.CodigoPDV equals (pdv.CodigoPDV)
where rup.IDMotivo != 6
//group rup by new { rup.IDRuptura} into gr
select new MontaArvoreAcao
{
IDRuptura = rup.IDRuptura,
DataRuptura = rup.DataRuptura,
IDMotivo = rup.IDMotivo,
Motivo = rup.Motivo.Motivo1,
IDOrigem = rup.IDOrigem,
CodigoPDV = rup.CodigoPDV,
UF = rup.PDV.UF,
Cidade = pdv.Cidade,
CnpjDescricao = pdv.Cnpj + " - " + pdv.Descricao,
Codigo_Apresentacao = rup.Codigo_Apresentacao,
Unidade_Negocio = ap.Unidade_Negocio,
Codigo_Unidade_Negocio = ap.Codigo_Unidade_Negocio,
Franquia = ap.Franquia,
Familia = ap.Familia,
Descricao = ap.Descricao,
Tipo_Rede = pdv.Tipo_PDV,
Farmacia = pdv.Descricao
}).ToList().OrderBy(r => r.IDMotivo);
return monta_arvore.ToList();
}
The parameters coming from the View are:
Estado, Cidade, Tipo_PDV, Descricao, UN, Familia de Produto.
I changed my Action to receive parameters, as you are seeing. How do I pass the parameters to these arguments?
public ActionResult Acao(string _uf, string _cidade, string _descricao)
{
string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split('\')[1].Trim();
ViewBag.User = user;
ViewData["ListaUn"] = MontaArvoreAcao.CriarListaArvoreUn(_uf,_cidade,_descricao);
ViewData["ListaFamilia"] = MontaArvoreAcao.CriarListaArvoreFamilia();
ViewData["ListaProd"] = MontaArvoreAcao.CriarListaArvoreProduto();
ViewData["ListaPdv"] = MontaArvoreAcao.CriarListaArvorePdv();
return View(MontaArvoreAcao.montaArvoreAcao());
}