public static void SalvarUsuario(AlarmItem alarm) { using (MyDbDataContext ctx = new MyDbDataContext()) { ctx.Alarmes.InsertOnSubmit(alarm); ctx.SubmitChanges(); } }
static AlarmeRepository() { using (MyDbDataContext ctx = new MyDbDataContext()) { if (!ctx.DatabaseExists()) ctx.CreateDatabase(); } }
public static void Update(AlarmItem alarmItem) { using (MyDbDataContext ctx = new MyDbDataContext()) { try { //var elem = ctx.Alarmes.updOrderByDescending(c => c.Id).FirstOrDefault(); foreach (var alart in ctx.Alarmes) { alart.Repeticao = alarmItem.Repeticao; } ctx.SubmitChanges(); } catch (Exception ex) { } } }
public static List<AlarmItem> GetAll() { MyDbDataContext ctx = new MyDbDataContext(); return ctx.Alarmes.ToList(); }