Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public JsonResult myControllerMethod() // Action Controller
- {
- using (AdsConnection conn = new AdsConnection(connString))
- {
- conn.Open();
- AdsTransaction txn = conn.BeginTransaction(); // Begin Transaction
- try
- {
- MyModel mo = new MyModel();
- mo.doProcess(conn); // pass connection to model
- txn.Commit();
- return Json(new { success = true });
- }
- catch (Exception e)
- {
- txn.Rollback();
- return Json(new { success = false, message = e.Message });
- }
- }
- }
- public void doProcess(AdsConncection conn){ // Model
- try{
- ..
- //AdsCommand select, update, delete and insert....
- ..
- }catch(Exception e){
- throw e;
- }
- }
Add Comment
Please, Sign In to add comment