Search in visual studio

0

To make a web proguama in visual basic how can I make a filter of an int type code and only appear clients with the code typed?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Nac.Models;

namespace Nac.Controllers
{
    public class ClienteController : Controller
    {
        // GET: Cliente
        public ActionResult Principal()
        {
            return View();
        }
        public ActionResult Cadastrar()
        {
            return View();
        }
        public ActionResult Buscar()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Cadastrar(Cliente c)
        {
            if (ModelState.IsValid)
            {
                Estoque e = Estoque.Instance();

                e.incluirCliente(c);

                return RedirectToAction("Listar");
            }

            return View(c);
        }

        public ActionResult Listar()
        {
            IEnumerable<Cliente> clientes = Estoque.Instance().listarClientes();
            return View(clientes);
        }

        public ActionResult Excluir(int id)
        {
            Estoque.Instance().excluirCliente(id);
            return RedirectToAction("Listar");
        }

        public ActionResult Editar(int id)
        {
            Cliente c = Estoque.Instance().listarCliente(id);
            return View("Cadastrar", c);
        }

        [HttpPost]
        public ActionResult Editar(Cliente c)
        {
            Estoque.Instance().alterarCliente(c);
            return RedirectToAction("Listar");
        }



    }
}
    
asked by anonymous 14.10.2016 / 02:55

1 answer

0
  • Create an Action that receives an int variable as a parameter.
  • Create a method to filter clients and pass the variable provided in Action as parameters.
  • Return customers found to your View.
  • Example:

    public ActionResult Buscar(int id)
    {
        IEnumerable<Cliente> clientes = BuscarClientesPorId(id);
        return View(clientes);
    }
    
        
    24.10.2016 / 10:32