public static bool Modificar(Cargos cargos) { bool paso = false; ContextoC db = new ContextoC(); try { db.Entry(cargos).State = EntityState.Modified; paso = (db.SaveChanges() > 0); } catch (Exception) { throw; } finally { db.Dispose(); } return(paso); }
public static bool Eliminar(int id) { bool paso = false; ContextoC db = new ContextoC(); try { var eliminar = db.Cargos.Find(id); db.Entry(eliminar).State = EntityState.Deleted; paso = (db.SaveChanges() > 0); } catch (Exception) { throw; } finally { db.Dispose(); } return(paso); }
public static bool Guardar(Cargos cargos) { bool paso = false; ContextoC db = new ContextoC(); try { if (db.Cargos.Add(cargos) != null) { paso = db.SaveChanges() > 0; } } catch (Exception) { throw; } finally { db.Dispose(); } return(paso); }