public void Put([FromBody] Cliente cliente)
 {
     if (cliente != null)
     {
         using (var dbCliente = new ClienteRep())
         {
             dbCliente.Update(cliente);
         }
     }
 }
 public void Delete([FromUri] int id)
 {
     if (id != 0)
     {
         using (var dbCliente = new ClienteRep())
         {
             dbCliente.Delete(id);
         }
     }
 }
 public void Post([FromBody] Cliente cliente)
 {
     if (cliente != null)
     {
         using (var dbCliente = new ClienteRep())
         {
             dbCliente.Insert(cliente);
         }
     }
 }
Example #4
0
 public static Cliente Buscar(int codigo)
 {
     try
     {
         return(ClienteRep.Buscar(codigo));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #5
0
 public static List <Cliente> Listar()
 {
     try
     {
         return(ClienteRep.Listar());
     }
     catch (Exception)
     {
         throw;
     }
 }
        public IEnumerable <Cliente> GetFilter([FromUri] int id = 0, string nome = null, string cpf = null, string sexo = null, string profissao = null)
        {
            using (var db = new ClienteRep())
            {
                List <Cliente> Clientes = db.GetFilter(id, nome, cpf, sexo, profissao).ToList();

                // if (Clientes.Any())
                return(Clientes.ToList());

                //return db.GetAll();
            }
        }
        public Cliente Get([FromUri] int id)
        {
            if (id != 0)
            {
                using (var db = new ClienteRep())
                {
                    return(db.Get(id));
                }
            }

            return(null);
        }
        public IActionResult Cadastrar([Bind] Cliente Cliente)

        {
            if (ModelState.IsValid)

            {
                ClienteRep objClienteRep = new ClienteRep();
                objClienteRep.Cadastrar(Cliente);

                return(RedirectToAction("Index"));
            }

            return(View(Cliente));
        }
        public IActionResult Editar(int id, [Bind] Cliente Cliente)
        {
            if (id != Cliente.IdCliente)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                ClienteRep objClienteRep = new ClienteRep();
                objClienteRep.Atualizar(Cliente);

                return(RedirectToAction("Index"));
            }

            return(View(Cliente));
        }
        public IActionResult Excluir(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ClienteRep objClienteRep = new ClienteRep();
            Cliente    Cliente       = objClienteRep.BuscarClientePorId(id);

            if (Cliente == null)
            {
                return(NotFound());
            }

            return(View(Cliente));
        }
        // GET: /<controller>/

        public IActionResult Index()

        {
            List <Cliente> lstCliente = new List <Cliente>();

            try

            {
                ClienteRep objClienteRep = new ClienteRep();
                lstCliente = objClienteRep.Listar().ToList();
            }

            catch (System.Exception ex)

            {
                TempData["Erro"] = ex.Message;
            }



            return(View(lstCliente));
        }
Example #12
0
 public static List <Cliente> Listar()
 {
     return(ClienteRep.Listar());
 }