コード例 #1
0
ファイル: GoodHelper.cs プロジェクト: ruvor/Atapy
 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;
     }
 }
コード例 #2
0
ファイル: GoodHelper.cs プロジェクト: ruvor/Atapy
 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)
     {
     }
 }