public static bool TransactionProcessing(MS_ACT_PAYMNT_CONFIRMATION_LOG log) { var db = new SibaModel(); using (var trans = db.Database.BeginTransaction()) { try { var dbPayment = db.MS_ACT_PAYMENTS_HEAD.Find(log.PCL_APH_SYS_ID); switch (log.PCL_ACTION) { case "Confirm": if (dbPayment != null) { db.MS_ACT_PAYMENTS_HEAD.Attach(dbPayment); dbPayment.APH_TRANS_STATUS = "C"; db.SaveChanges(); //take log of the change in the transacitonal status of the receipt db.MS_ACT_PAYMNT_CONFIRMATION_LOG.Add(log); db.SaveChanges(); } else { return(false); } break; case "Unconfirm": if (dbPayment != null) { db.MS_ACT_PAYMENTS_HEAD.Attach(dbPayment); dbPayment.APH_TRANS_STATUS = "P"; db.SaveChanges(); //take log of the change in the transacitonal status of the receipt db.MS_ACT_PAYMNT_CONFIRMATION_LOG.Add(log); db.SaveChanges(); } else { return(false); } break; } trans.Commit(); return(true); } catch (Exception) { trans.Rollback(); throw; } } }
public object Transaction([FromBody] MS_ACT_PAYMNT_CONFIRMATION_LOG log) { try { var result = AccountPaymentMdl.TransactionProcessing(log); return(new { state = true, message = log.PCL_ACTION == "Confirm" ? "Account Payment Successfully Confirmed" : "Account Payment Successfully Unconfirmed" }); } catch (Exception e) { return(new { state = false, message = "Server Error", exception = e }); } }