public Exception dbRemoveGood() { try { using (AtapyContext db = new AtapyContext()) { Good good = db.Goods.Where(x => x.GoodId == baseId).FirstOrDefault(); if (good != null) { db.Goods.Remove(good); } db.SaveChanges(); } return null; } catch (Exception ex) { return ex; } }
public void dbSaveGood() { try { using (AtapyContext db = new AtapyContext()) { Good good = new Good { GoodType = goodType, GoodCategory = goodCategory, ProductName = productName, Price = price, Barcode = barcode, OtherPropertiesJSON = otherPropertiesJSON }; db.Database.Connection.Open(); db.Goods.Add(good); db.SaveChanges(); baseId = good.GoodId; } } catch (Exception ex) { } }