Ejemplo n.º 1
0
        public List <departamento> ListarDepartamentos()
        {
            var Departamentos = new List <departamento>();

            try
            {
                using (var context = new TransContext())
                {
                    Departamentos = context.departamento.ToList();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(Departamentos);
        }
Ejemplo n.º 2
0
        public clientes getCliente(int id)
        {
            var Cliente = new clientes();

            try
            {
                using (var context = new TransContext())
                {
                    Cliente = context.clientes.Include("departamento1").Where(x => x.id == id).Single();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(Cliente);
        }
Ejemplo n.º 3
0
        public List <clientes> ListarClientes()
        {
            var Clientes = new List <clientes>();

            try
            {
                using (var context = new TransContext())
                {
                    Clientes = context.clientes.ToList();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(Clientes);
        }
Ejemplo n.º 4
0
 public void Guardar()
 {
     try
     {
         using (var context = new TransContext())
         {
             //if(this.id == 0)
             //{
             context.Entry(this).State = EntityState.Added;
             //}
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }