Guest User

Untitled

a guest
Jan 20th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment