internal static DoResult Do(long?userId, Action <DoController> action) { var controller = new DoController(); try { controller.Db.Database.Connection.Open(); action(controller); } catch (Exception ex) { controller.SetError(ex.Message, -1); } finally { controller.Db.Database.Connection.Close(); } return(controller.Result); }
internal static DoResult <T> Do <T>(long?userId, Func <DoController <T>, T> action) { var controller = new DoController <T>(); try { controller.Db.Database.Connection.Open(); controller.Result.Result = action(controller); } catch (Exception ex) { controller.Result.Result = controller.FailResult; controller.SetError(ex.Message, -1); } finally { controller.Db.Database.Connection.Close(); } return(controller.Result); }
internal static DoResult Do(Action <DoController> action, GiaSinhVienEntities db = null) { var controller = new DoController(db); try { if (db == null) { controller.Db.Database.Connection.Open(); } action(controller); } catch (Exception ex) { controller.SetError(ex.Message, -1); } finally { controller.Db.Database.Connection.Close(); } return(controller.Result); }
internal static DoResult <T> Do <T>(Func <DoController <T>, T> action, GiaSinhVienEntities db = null) { var controller = new DoController <T>(db); try { if (db == null) { controller.Db.Database.Connection.Open(); } controller.Result.Result = action(controller); } catch (Exception ex) { controller.Result.Result = controller.FailResult; controller.SetError(ex.Message, -1); } finally { controller.Db.Database.Connection.Close(); } return(controller.Result); }