public void OrderRemove(int id) { using (var ctx = new TestDatabaseEntities()) { Order res = ctx.Orders.Where(o => o.id == id).First(); ctx.Entry(res).State = EntityState.Deleted; ctx.SaveChanges(); } }
public bool OrderUpdate(Order o) { using (var ctx = new TestDatabaseEntities()) { Order ordUpdate = ctx.Orders.Where(or => or.id == o.id).First(); if (ordUpdate != null) { ordUpdate.Price = o.Price; ordUpdate.Description = o.Description; } else { return false; } ctx.Entry(ordUpdate).State = EntityState.Modified; ctx.SaveChanges(); } return true; }
public bool Update(Worker item) { using (var ctx = new TestDatabaseEntities()) { Worker wrkUpdate = ctx.Workers.Where(w => w.id == item.id).First(); if (wrkUpdate != null) { wrkUpdate.FirstName = item.FirstName; wrkUpdate.LastName = item.LastName; wrkUpdate.Position = item.Position; wrkUpdate.Phone = item.Phone; } else { return false; } ctx.Entry(wrkUpdate).State = EntityState.Modified; ctx.SaveChanges(); } return true; }