public ActionResult New() { List <Plan> Planox = new List <Plan>(); Planox = _context.Plan.ToList(); PlanUserViewModel viewModel = new PlanUserViewModel() { Planos = Planox, }; return(View(viewModel)); }
public ActionResult New() { //Listar Plan , e _context para abri na db, mas para que isso aconteça há que instanciar a PlanUserViewModel porque Plano é um modelo diferente de Client e so podemos passar um modelo para a view List<Plan> Planox = new List<Plan>(); Planox = _context.Plan.ToList(); PlanUserViewModel viewModel = new PlanUserViewModel() { Cliente = new Client(), Planos = Planox, }; ViewBag.Acao = "Novo Cliente"; return View(viewModel); }
// Edit a variavel client via encontar um id ja criado , depois da validação public ActionResult Edit(int Id) { var client = _context.Client.Find(Id); if(client == null) { return HttpNotFound(); } List<Plan> Planox = new List<Plan>(); Planox = _context.Plan.ToList(); var viewModel = new PlanUserViewModel() { Planos = Planox, Cliente = client }; ViewBag.Acao = "Editar Cliente"; return View("New",viewModel); }
public ActionResult Index() { Client user = new Client(); user.Name = "Vitor"; var ListPlan = new List <Plan>() { new Models.Plan() { Id = 1, Name = "Plano 1", Value = 100 }, new Models.Plan() { Id = 2, Name = "Plano 2", Value = 200 } }; var ListPlan2 = new List <Plan2>() { new Models.Plan2() { Id = 1, Name = "Plano A", Modalidade = "Futebol", Value = 100 }, new Models.Plan2() { Id = 2, Name = "Plano B", Modalidade = "Natação", Value = 200 } }; PlanUserViewModel model = new PlanUserViewModel(); model.Cliente = user; model.Planos = ListPlan; model.PlanoA = ListPlan2; return(View(model)); }