Some refactorings
This commit is contained in:
14
TrackerLibrary/Enums.cs
Normal file
14
TrackerLibrary/Enums.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TrackerLibrary
|
||||||
|
{
|
||||||
|
public enum DatabaseType
|
||||||
|
{
|
||||||
|
Sql,
|
||||||
|
TextFile
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,23 +8,27 @@ namespace TrackerLibrary
|
|||||||
{
|
{
|
||||||
public static class GlobalConfig
|
public static class GlobalConfig
|
||||||
{
|
{
|
||||||
public static List<IDataConnection> Connections { get; private set; } = new List<IDataConnection>();
|
public static IDataConnection Connection { get; private set; }
|
||||||
public static void InitializeConnections(bool database, bool textFiles)
|
public static void InitializeConnections(DatabaseType db)
|
||||||
{
|
{
|
||||||
if (database)
|
|
||||||
|
switch (db)
|
||||||
{
|
{
|
||||||
// TODO - Set up the sql connector properly !
|
case DatabaseType.Sql:
|
||||||
SqlConnector sql = new SqlConnector();
|
// TODO - Set up the sql connector properly !
|
||||||
Connections.Add(sql);
|
SqlConnector sql = new SqlConnector();
|
||||||
}
|
Connection = sql;
|
||||||
|
break;
|
||||||
if (textFiles)
|
case DatabaseType.TextFile:
|
||||||
{
|
// TODO - Create the text Connection
|
||||||
// TODO - Create the text Connection
|
TextConnector text = new TextConnector();
|
||||||
TextConnector text = new TextConnector();
|
Connection = text;
|
||||||
Connections.Add(text);
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string CnnString(string name)
|
public static string CnnString(string name)
|
||||||
|
|||||||
@ -48,6 +48,7 @@
|
|||||||
<Compile Include="DataAccess\IDataConnection.cs" />
|
<Compile Include="DataAccess\IDataConnection.cs" />
|
||||||
<Compile Include="DataAccess\SqlConnector.cs" />
|
<Compile Include="DataAccess\SqlConnector.cs" />
|
||||||
<Compile Include="DataAccess\TextConnector.cs" />
|
<Compile Include="DataAccess\TextConnector.cs" />
|
||||||
|
<Compile Include="Enums.cs" />
|
||||||
<Compile Include="GlobalConfig.cs" />
|
<Compile Include="GlobalConfig.cs" />
|
||||||
<Compile Include="Models\MatchupEntryModel.cs" />
|
<Compile Include="Models\MatchupEntryModel.cs" />
|
||||||
<Compile Include="Models\MatchupModel.cs" />
|
<Compile Include="Models\MatchupModel.cs" />
|
||||||
|
|||||||
@ -29,10 +29,7 @@ namespace TrackerUI
|
|||||||
prizeAmountValue.Text,
|
prizeAmountValue.Text,
|
||||||
prizePercentageValue.Text);
|
prizePercentageValue.Text);
|
||||||
|
|
||||||
foreach (var db in GlobalConfig.Connections)
|
GlobalConfig.Connection.CreatePrize(model);
|
||||||
{
|
|
||||||
db.CreatePrize(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
placeNameValue.Text = "";
|
placeNameValue.Text = "";
|
||||||
placeNumberValue.Text = "";
|
placeNumberValue.Text = "";
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using TrackerLibrary;
|
||||||
|
|
||||||
namespace TrackerUI
|
namespace TrackerUI
|
||||||
{
|
{
|
||||||
@ -18,7 +19,7 @@ namespace TrackerUI
|
|||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
// Initialize the database connections
|
// Initialize the database connections
|
||||||
TrackerLibrary.GlobalConfig.InitializeConnections(true, true);
|
GlobalConfig.InitializeConnections(DatabaseType.Sql);
|
||||||
Application.Run(new CreatePrizeForm());
|
Application.Run(new CreatePrizeForm());
|
||||||
|
|
||||||
//Application.Run(new TournamentDashboardForm());
|
//Application.Run(new TournamentDashboardForm());
|
||||||
|
|||||||
Reference in New Issue
Block a user