public Boolean DeleteTable(Int32 id) { Table query = new Table(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query = db.Tables.FirstOrDefault(m => m.id == id); if (query != default(Table)) { query.Status = (Int32)Common.Status.NotActive; db.SubmitChanges(); } } } catch (Exception ex) { return false; } return true; }
public Boolean SaveTables(List<Table> tables, Int32 floorId) { Table table; IEnumerable<Table> tablesToDelete; try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { tablesToDelete = db.Tables.Where(m => m.FloorId == floorId && !tables.Contains(m)); if (tablesToDelete.Any()) { db.Tables.DeleteAllOnSubmit(tablesToDelete); db.SubmitChanges(); } if (tables.Any()) { foreach (Table t in tables) { table = new Table(); if (t.id != 0) { table = db.Tables.FirstOrDefault(m => m.id == t.id); } table.Top = t.Top; table.FloorId = floorId; table.Name = t.Name; table.Left = t.Left; table.Status = (Int32)Common.Status.Active; table.Type = t.Type; table.Width = t.Width; table.Height = t.Height; if (t.id == 0) { db.Tables.InsertOnSubmit(table); } db.SubmitChanges(); } } } } catch (Exception ex) { return false; } return true; }
partial void DeleteTable(Table instance);
partial void UpdateTable(Table instance);
partial void InsertTable(Table instance);
private void detach_Tables(Table entity) { this.SendPropertyChanging(); entity.Floor = null; }
private void attach_Tables(Table entity) { this.SendPropertyChanging(); entity.Floor = this; }