Exemplo n.º 1
0
        public static List <Cargo> GetList(Expression <Func <Cargo, bool> > cargos)
        {
            List <Cargo>  people = new List <Cargo>();
            ContextoCargo db     = new ContextoCargo();

            try
            {
                people = db.cargos.Where(cargos).ToList();
                db.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            return(people);
        }
Exemplo n.º 2
0
        public static Cargo Buscar(int CargoId)
        {
            ContextoCargo db     = new ContextoCargo();
            Cargo         cargos = new Cargo();

            try
            {
                cargos = db.cargos.Find(CargoId);
                db.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            return(cargos);
        }
Exemplo n.º 3
0
        public static bool Modificar(Cargo cargos)
        {
            bool          paso = false;
            ContextoCargo db   = new ContextoCargo();

            try
            {
                db.Entry(cargos).State = System.Data.Entity.EntityState.Modified;
                paso = (db.SaveChanges() > 0);
                db.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            return(paso);
        }
Exemplo n.º 4
0
        public static bool Guardar(Cargo cargos)
        {
            bool          paso = false;
            ContextoCargo db   = new ContextoCargo();

            try
            {
                if (db.cargos.Add(cargos) != null)
                {
                    db.SaveChanges();
                    paso = true;
                }

                db.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
            return(paso);
        }
Exemplo n.º 5
0
        public static bool Eliminar(int CargoId)
        {
            bool          paso = false;
            ContextoCargo db   = new ContextoCargo();

            try
            {
                var eliminar = db.cargos.Find(CargoId);
                //db.Persona.Remove(eliminar);
                db.Entry(eliminar).State = EntityState.Deleted;
                paso = (db.SaveChanges() > 0);
            }
            catch (Exception)
            {
                throw;
            }

            finally
            {
                db.Dispose();
            }
            return(paso);
        }