public bool UpdateApelSeara(int id_c, int efc, int efp, int efa, DateTime data, int code) { if (code == 0) return false; using (var context = new ServiciiATMContext()) { using (var transaction = context.Database.BeginTransaction()) { try { var apel = new Apel_seara { ID_C = id_c }; context.Apel_seara.Attach(apel); context.Entry(apel).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); transaction.Commit(); return true; } catch (Exception ex) { transaction.Rollback(); return false; } } } }
public bool InsertApelSeara(int id_c, int efc, int efp, int efa, DateTime data, int code) { if (code == 0) return false; using (var context = new ServiciiATMContext()) { var apel = new Apel_seara { ID_C = id_c, Efectiv_control = efc, Efectiv_prezenti = efp, Efectiv_absenti = efa, Data = data, }; context.Apel_seara.Add(apel); context.Entry(apel).State = System.Data.Entity.EntityState.Added; context.SaveChanges(); return true; } }