0
I have that class:
public class MontaArvoreAcao
{
public int IDRuptura { get; set; }
public DateTime DataRuptura { get; set; }
public int IDMotivo { get; set; }
public string Motivo { get; set; }
public int IDOrigem { get; set; }
public string CodigoPDV { get; set; }
public string UF { get; set; }
public string Cidade { get; set; }
public string Cnpj { get; set; }
public string Descricao { get; set; }
public string Codigo_Apresentacao { get; set; }
public string Unidade_Negocio { get; set; }
public string Franquia { get; set; }
public string Familia { get; set; }
public string Descricao { get; set; }
}
The purpose of this class is for me to have a Model that I can take in my view and work with there. This class(Model) will be fed with this code into the controller:
[HttpPost]
public JsonResult ArvoreAcao(string _uf)
{
RupturaEntities db = new RupturaEntities();
var monta_arvore = (from rup in db.Ruptura
from apr in db.Apresentacao.Where(apr => apr.Codigo_Apresentacao == rup.Codigo_Apresentacao)
from pdv in db.PDV.Where(pdv => pdv.CodigoPDV == rup.CodigoPDV)
from mot in db.Motivo.Where(mot => mot.IDMotivo == rup.IDMotivo)
select new {
rup.IDRuptura,
rup.DataRuptura,
rup.IDMotivo,
mot.Motivo1,
rup.IDOrigem,
rup.CodigoPDV,
pdv.UF,
pdv.Cidade,
loja = pdv.Cnpj + " - " + pdv.Descricao,
rup.Codigo_Apresentacao,
apr.Unidade_Negocio,
apr.Franquia,
apr.Familia,
apr.Descricao}).ToList().Distinct().OrderBy(apr => apr.Descricao);
ViewBag.result_arvore = monta_arvore;
return Json(new { monta_arvore}, JsonRequestBehavior.AllowGet);
}
The question is: How do I get this Model in the View with all the values coming from the above, that is, from the database? One more question: All ID’s in this class are Foreign Key. Is it right to represent a Foreign Key as in class or do I have to do a Icollection?
Luidy, initially I was like this and copied and sent as was. This way I have no problems with anything, except that in the View I need to set up a checkbox and with Jquery is not mounting. Bring the information, but do not assemble the checks as I put in another post. Then, I had the idea to do directly in cshtml to see if I can work.
– pnet
Hello, you got help in your other post on how to set up checkboxes ? If not, send the link so I can see it and try to help you, please. Abs.
– Luidy
No, it’s still open. If I can do with jquery it’s all I’d like.
– pnet
Which link to your post?
– Luidy
http://answall.com/questions/32100/carregar-dinamicamente-do-banco-e-montar-um-treeview-no-cshtml-n%C3%A3o-estou-consegu
– pnet