static void insertProduct(AssemblyCard card) { using (var db = new CardsContext()) { db.Add(card); db.SaveChanges(); } }
static void deleteProduct(string id) { using (var db = new CardsContext()) { AssemblyCard card = db.Cards.SingleOrDefault(r => r.CardId == id); if (card == null) { return; } db.Cards.Remove(card); db.SaveChanges(); } }
static void updateProduct(AssemblyCard card) { using (var db = new CardsContext()) { AssemblyCard savedCard = db.Cards.SingleOrDefault(r => r.CardId == card.CardId); if (savedCard == null) { return; } savedCard.EmployeeFN = card.EmployeeFN; savedCard.EmployeeLN = card.EmployeeLN; savedCard.EmployeeID = card.EmployeeID; savedCard.KNNR = card.KNNR; savedCard.Sort = card.Sort; db.SaveChanges(); } }