Wireup window with access methods + refaktor structure
This commit is contained in:
12
TrackerLibrary/DataAccess/IDataConnection.cs
Normal file
12
TrackerLibrary/DataAccess/IDataConnection.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TrackerLibrary.Models;
|
||||
|
||||
namespace TrackerLibrary.DataAccess
|
||||
{
|
||||
public interface IDataConnection
|
||||
{
|
||||
PrizeModel CreatePrize(PrizeModel model);
|
||||
}
|
||||
}
|
||||
21
TrackerLibrary/DataAccess/SqlConnector.cs
Normal file
21
TrackerLibrary/DataAccess/SqlConnector.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary.DataAccess
|
||||
{
|
||||
public class SqlConnector : IDataConnection
|
||||
{
|
||||
// TODO - Make the CreatePrize method actually save to the database
|
||||
/// <summary>
|
||||
/// Saves a prize to the database
|
||||
/// </summary>
|
||||
/// <param name="model">The prize information.</param>
|
||||
/// <returns>The prize information, including the unique identifier.</returns>
|
||||
public Models.PrizeModel CreatePrize(Models.PrizeModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
TrackerLibrary/DataAccess/TextConnector.cs
Normal file
17
TrackerLibrary/DataAccess/TextConnector.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TrackerLibrary.Models;
|
||||
|
||||
namespace TrackerLibrary.DataAccess
|
||||
{
|
||||
public class TextConnector : IDataConnection
|
||||
{
|
||||
// TODO - Wire up the createPrize for textFiles
|
||||
public PrizeModel CreatePrize(PrizeModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
TrackerLibrary/GlobalConfig.cs
Normal file
28
TrackerLibrary/GlobalConfig.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TrackerLibrary.DataAccess;
|
||||
|
||||
namespace TrackerLibrary
|
||||
{
|
||||
public static class GlobalConfig
|
||||
{
|
||||
public static List<IDataConnection> Connections { get; private set; } = new List<IDataConnection>();
|
||||
public static void InitializeConnections(bool database, bool textFiles)
|
||||
{
|
||||
if (database)
|
||||
{
|
||||
// TODO - Set up the sql connector properly !
|
||||
SqlConnector sql = new SqlConnector();
|
||||
Connections.Add(sql);
|
||||
}
|
||||
|
||||
if (textFiles)
|
||||
{
|
||||
// TODO - Create the text Connection
|
||||
TextConnector text = new TextConnector();
|
||||
Connections.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary
|
||||
namespace TrackerLibrary.Models
|
||||
{
|
||||
public class MatchupEntryModel
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary
|
||||
namespace TrackerLibrary.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents one match in the tournament.
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary
|
||||
namespace TrackerLibrary.Models
|
||||
{
|
||||
public class PersonModel
|
||||
{
|
||||
40
TrackerLibrary/Models/PrizeModel.cs
Normal file
40
TrackerLibrary/Models/PrizeModel.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary.Models
|
||||
{
|
||||
public class PrizeModel
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// The unique identifier for the prize
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
public int PlaceNumber { get; set; }
|
||||
public string PlaceName { get; set; }
|
||||
public decimal PrizeAmount { get; set; }
|
||||
public double PrizePercentage { get; set; }
|
||||
|
||||
public PrizeModel()
|
||||
{
|
||||
|
||||
}
|
||||
public PrizeModel(string placeName, string placeNumber, string prizeAmount, string prizePercentage)
|
||||
{
|
||||
PlaceName = placeName;
|
||||
|
||||
int placeNumberValue = 0;
|
||||
int.TryParse(placeNumber, out placeNumberValue);
|
||||
PlaceNumber = placeNumberValue;
|
||||
|
||||
decimal prizeAmountValue = 0;
|
||||
decimal.TryParse(prizeAmount, out prizeAmountValue);
|
||||
PrizeAmount = prizeAmountValue;
|
||||
|
||||
double prizePercentageValue = 0;
|
||||
double.TryParse(prizePercentage, out prizePercentageValue);
|
||||
PrizePercentage = prizePercentageValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary
|
||||
namespace TrackerLibrary.Models
|
||||
{
|
||||
public class TeamModel
|
||||
{
|
||||
15
TrackerLibrary/Models/TournamentModel.cs
Normal file
15
TrackerLibrary/Models/TournamentModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary.Models
|
||||
{
|
||||
public class TournamentModel
|
||||
{
|
||||
public string TournamentName { get; set; }
|
||||
public decimal EntryFee { get; set; }
|
||||
public List<Models.TeamModel> EnteredTeams { get; set; } = new List<Models.TeamModel>();
|
||||
public List<Models.PrizeModel> Prizes { get; set; } = new List<Models.PrizeModel>();
|
||||
public List<List<Models.MatchupModel>> MyProperty { get; set; } = new List<List<Models.MatchupModel>>();
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary
|
||||
{
|
||||
public class PrizeModel
|
||||
|
||||
{
|
||||
public int PlaceNumber { get; set; }
|
||||
public string PlaceName { get; set; }
|
||||
public decimal PrizeAmount { get; set; }
|
||||
public double PrizePercentage { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TrackerLibrary
|
||||
{
|
||||
public class TournamentModel
|
||||
{
|
||||
public string TournamentName { get; set; }
|
||||
public decimal EntryFee { get; set; }
|
||||
public List<TeamModel> EnteredTeams { get; set; } = new List<TeamModel>();
|
||||
public List<PrizeModel> Prizes { get; set; } = new List<PrizeModel>();
|
||||
public List<List<MatchupModel>> MyProperty { get; set; } = new List<List<MatchupModel>>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user