public bool Eliminar(TEntity laEntidad)
 {
     try
     {
         EntitySet.Attach(laEntidad);
         EntitySet.Remove(laEntidad);
         return(Context.SaveChanges() > 0);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #2
0
        public bool Eliminar(TEntity criterio)
        {
            bool result = false;

            try
            {
                EntitySet.Attach(criterio);
                EntitySet.Remove(criterio);
                result = context.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
        public TEntity Guardar(TEntity laEntidad)
        {
            TEntity Result = null;

            try
            {
                EntitySet.Add(laEntidad);
                Contex.SaveChanges();
                Result = laEntidad;
            }
            catch (Exception)
            {
                throw;
            }

            return(Result);
        }
Beispiel #4
0
        public static bool Guardar(Entidades.Empleados empleado)
        {
            using (var conec = new DAL.ParcialDb())
            {
                try
                {
                    conec.Empleado.Add(empleado);

                    foreach (var g in empleado.Retenciones)
                    {
                        conec.Entry(g).State = System.Data.Entity.EntityState.Unchanged;
                    }

                    conec.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(false);
        }