public static bool AddSiteSettings(SiteSettings siteSettings, int requestId, int siteQty) { Database database = DatabaseFactory.CreateDatabase(); bool result; using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { DistributorProvider distributorProvider = DistributorProvider.Instance(); if (!distributorProvider.AcceptSiteRequest(siteQty, requestId, dbTransaction)) { dbTransaction.Rollback(); result = false; } else { if (!distributorProvider.AddSiteSettings(siteSettings, requestId, dbTransaction)) { dbTransaction.Rollback(); result = false; } else { if (!DistributorProvider.Instance().AddInitData(siteSettings.UserId.Value, dbTransaction)) { dbTransaction.Rollback(); result = false; } else { dbTransaction.Commit(); result = true; } } } } catch { dbTransaction.Rollback(); result = false; } finally { dbConnection.Close(); } } return(result); }
public static bool AddSiteSettings(SiteSettings siteSettings, int requestId, int siteQty) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { DistributorProvider provider = DistributorProvider.Instance(); if (!provider.AcceptSiteRequest(siteQty, requestId, dbTran)) { dbTran.Rollback(); return(false); } if (!provider.AddSiteSettings(siteSettings, requestId, dbTran)) { dbTran.Rollback(); return(false); } if (!DistributorProvider.Instance().AddInitData(siteSettings.UserId.Value, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }