// GET: Client
        public ActionResult Index()
        {
            _repository = new ClientRepository();
            var clients = _repository.Clients;

            return View(clients);
        }
        public ViewResult Edit(int idClient)
        {
            _repository = new ClientRepository();
            Client client = _repository.Clients.FirstOrDefault(p => p.idClient == idClient);

            return View(client);
        }
        public ActionResult Delete(int idClient)
        {
            _repository = new ClientRepository();

            Client cli = _repository.Delete(idClient);

            if (cli != null)
            {
                TempData["mensagem"] = string.Format("{0} was deleted", cli.Name);
            }

            return RedirectToAction("Index");
        }
        public ActionResult Edit(Client client)
        {
            if (ModelState.IsValid)
            {
                String msg = client.idClient == 0 ? "created" : "updated";
                _repository = new ClientRepository();
                _repository.Save(client);

                TempData["mensagem"] = string.Format("{0} was {1}", client.Name, msg);

                return RedirectToAction("Index");
            }

            return View(client);
        }
 public ActionResult Count(String name)
 {
     _repository = new ClientRepository();
     List<CountClients> r = _repository.QueryCount ();
     return View(r);
 }
 public ActionResult ByName(string searchname)
 {
     _repository = new ClientRepository();
     var r = _repository.QueryByName(searchname);
     return PartialView("_ByName", r);
 }