daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public JsonResult myControllerMethod() // Action Controller
  2. {
  3.     using (AdsConnection conn = new AdsConnection(connString))
  4.     {
  5.     conn.Open();
  6.     AdsTransaction txn = conn.BeginTransaction(); // Begin Transaction
  7.     try
  8.     {
  9.         MyModel mo = new MyModel();
  10.         mo.doProcess(conn); // pass connection to model
  11.         txn.Commit();
  12.         return Json(new { success = true });
  13.     }
  14.     catch (Exception e)
  15.     {
  16.         txn.Rollback();
  17.         return Json(new { success = false, message = e.Message });
  18.     }
  19.     }
  20. }
  21.    
  22. public void doProcess(AdsConncection conn){ // Model
  23.     try{
  24.         ..
  25.         //AdsCommand select, update, delete and insert....
  26.         ..
  27.     }catch(Exception e){
  28.         throw e;
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top