public static bool AddGroupBuy(GroupBuyInfo groupBuy) { Globals.EntityCoding(groupBuy, true); Database database = DatabaseFactory.CreateDatabase(); bool result; using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { GroupBuyDao groupBuyDao = new GroupBuyDao(); int num = groupBuyDao.AddGroupBuy(groupBuy, dbTransaction); if (num <= 0) { dbTransaction.Rollback(); result = false; } else { if (!groupBuyDao.AddGroupBuyCondition(num, groupBuy.GroupBuyConditions, dbTransaction)) { dbTransaction.Rollback(); result = false; } else { dbTransaction.Commit(); result = true; } } } catch (Exception var_5_7C) { dbTransaction.Rollback(); result = false; } finally { dbConnection.Close(); } } return(result); }
public static bool AddGroupBuy(GroupBuyInfo groupBuy) { bool flag; Globals.EntityCoding(groupBuy, true); using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { GroupBuyDao dao = new GroupBuyDao(); int groupBuyId = dao.AddGroupBuy(groupBuy, dbTran); if (groupBuyId <= 0) { dbTran.Rollback(); return(false); } if (!dao.AddGroupBuyCondition(groupBuyId, groupBuy.GroupBuyConditions, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }