コード例 #1
0
 public void UpdateAmount(double cost)
 {
     try
     {
         using (var db = new VendMachineDbContext())
         {
             Account Account = db.Accounts.Where(x => x.CardNO == cardNo).FirstOrDefault();
             Account.Amount         -= cost;
             db.Entry(Account).State = EntityState.Modified;
             db.SaveChanges();
             log.Info("Payment success");
         }
     }
     catch (Exception)
     {
         log.Error("Db connection failed");
     }
 }