Every form is wired up and the system works in some meaning
This commit is contained in:
@ -282,7 +282,7 @@ namespace TrackerLibrary.DataAccess
|
|||||||
int currRound = 1;
|
int currRound = 1;
|
||||||
foreach (MatchupModel m in matchups)
|
foreach (MatchupModel m in matchups)
|
||||||
{
|
{
|
||||||
if(m.MatchupRound > currRound)
|
if (m.MatchupRound > currRound)
|
||||||
{
|
{
|
||||||
t.Rounds.Add(currRow);
|
t.Rounds.Add(currRow);
|
||||||
currRow = new List<MatchupModel>();
|
currRow = new List<MatchupModel>();
|
||||||
@ -299,7 +299,28 @@ namespace TrackerLibrary.DataAccess
|
|||||||
|
|
||||||
public void UpdateMatchup(MatchupModel model)
|
public void UpdateMatchup(MatchupModel model)
|
||||||
{
|
{
|
||||||
|
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
|
||||||
|
{
|
||||||
|
var p = new DynamicParameters();
|
||||||
|
if (model.Winner != null)
|
||||||
|
{
|
||||||
|
p.Add("@Id", model.Id);
|
||||||
|
p.Add("@WinnerId", model.Winner.Id);
|
||||||
|
|
||||||
|
connection.Execute("dbo.spMatchups_Update", p, commandType: CommandType.StoredProcedure);
|
||||||
|
}
|
||||||
|
foreach (MatchupEntryModel m in model.Entries)
|
||||||
|
{
|
||||||
|
if (m.TeamCompeting != null)
|
||||||
|
{
|
||||||
|
p = new DynamicParameters();
|
||||||
|
p.Add("@Id", m.Id);
|
||||||
|
p.Add("@TeamCompetingId", m.TeamCompeting.Id);
|
||||||
|
p.Add("@Score", m.Score);
|
||||||
|
connection.Execute("dbo.spMatchupEntries_Update", p, commandType: CommandType.StoredProcedure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,7 +134,7 @@ namespace TrackerLibrary.DataAccess
|
|||||||
|
|
||||||
public void UpdateMatchup(MatchupModel model)
|
public void UpdateMatchup(MatchupModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
model.UpdateMatchupToFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -349,6 +349,42 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
File.WriteAllLines(GlobalConfig.MatchupFile.FullFilePath(), lines);
|
File.WriteAllLines(GlobalConfig.MatchupFile.FullFilePath(), lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateMatchupToFile(this MatchupModel matchup)
|
||||||
|
{
|
||||||
|
List<MatchupModel> matchups = GlobalConfig.MatchupFile.FullFilePath().LoadFile().ConvertToMatchupModels();
|
||||||
|
|
||||||
|
MatchupModel oldMatchup = new MatchupModel();
|
||||||
|
foreach (MatchupModel m in matchups)
|
||||||
|
{
|
||||||
|
if(m.Id == matchup.Id)
|
||||||
|
{
|
||||||
|
oldMatchup = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
matchups.Remove(oldMatchup);
|
||||||
|
|
||||||
|
matchups.Add(matchup);
|
||||||
|
|
||||||
|
foreach (MatchupEntryModel entry in matchup.Entries)
|
||||||
|
{
|
||||||
|
entry.UpdateEntryToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> lines = new List<string>();
|
||||||
|
foreach (MatchupModel m in matchups)
|
||||||
|
{
|
||||||
|
string winner = "";
|
||||||
|
if (m.Winner != null)
|
||||||
|
{
|
||||||
|
winner = m.Winner.Id.ToString(); ;
|
||||||
|
}
|
||||||
|
lines.Add($"{m.Id},{ConvertMatchupEntryListToString(m.Entries)},{winner},{m.MatchupRound}");
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllLines(GlobalConfig.MatchupFile.FullFilePath(), lines);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SaveEntryToFile(this MatchupEntryModel entry, string matchupEntryFile)
|
public static void SaveEntryToFile(this MatchupEntryModel entry, string matchupEntryFile)
|
||||||
{
|
{
|
||||||
List<MatchupEntryModel> entries = GlobalConfig.MatchupEntryFile.FullFilePath().LoadFile().ConvertToMatchupEntryModels();
|
List<MatchupEntryModel> entries = GlobalConfig.MatchupEntryFile.FullFilePath().LoadFile().ConvertToMatchupEntryModels();
|
||||||
@ -380,6 +416,42 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateEntryToFile(this MatchupEntryModel entry)
|
||||||
|
{
|
||||||
|
List<MatchupEntryModel> entries = GlobalConfig.MatchupEntryFile.FullFilePath().LoadFile().ConvertToMatchupEntryModels();
|
||||||
|
|
||||||
|
MatchupEntryModel oldEntry = new MatchupEntryModel();
|
||||||
|
foreach (MatchupEntryModel me in entries)
|
||||||
|
{
|
||||||
|
if(me.Id == entry.Id)
|
||||||
|
{
|
||||||
|
oldEntry = me;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entries.Remove(oldEntry);
|
||||||
|
entries.Add(entry);
|
||||||
|
|
||||||
|
List<string> lines = new List<string>();
|
||||||
|
foreach (MatchupEntryModel e in entries)
|
||||||
|
{
|
||||||
|
string parent = "";
|
||||||
|
if (e.ParentMatchup != null)
|
||||||
|
{
|
||||||
|
parent = e.ParentMatchup.Id.ToString();
|
||||||
|
}
|
||||||
|
string teamCompeting = "";
|
||||||
|
if (e.TeamCompeting != null)
|
||||||
|
{
|
||||||
|
teamCompeting = e.TeamCompeting.Id.ToString();
|
||||||
|
}
|
||||||
|
lines.Add($"{e.Id},{teamCompeting},{e.Score},{parent}");
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllLines(GlobalConfig.MatchupEntryFile.FullFilePath(), lines);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void SaveToTournamentFile(this List<TournamentModel> models, string fileName)
|
public static void SaveToTournamentFile(this List<TournamentModel> models, string fileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="filePath" value="D:\data\TournamentTracker"/>
|
<!--<add key="filePath" value="D:\data\TournamentTracker"/>-->
|
||||||
|
<add key="filePath" value="C:\AppData\TournamentTracker"/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<add name="Tournaments" connectionString="Server=TOMMYASUS\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>
|
<add name="Tournaments" connectionString="Server=TOMMYASUS\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using TrackerLibrary;
|
||||||
using TrackerLibrary.Models;
|
using TrackerLibrary.Models;
|
||||||
|
|
||||||
namespace TrackerUI
|
namespace TrackerUI
|
||||||
@ -214,7 +215,28 @@ namespace TrackerUI
|
|||||||
MessageBox.Show("I dont handle tie games.");
|
MessageBox.Show("I dont handle tie games.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (List<MatchupModel> round in tournament.Rounds)
|
||||||
|
{
|
||||||
|
foreach (MatchupModel rm in round)
|
||||||
|
{
|
||||||
|
foreach (MatchupEntryModel me in rm.Entries)
|
||||||
|
{
|
||||||
|
if (me.ParentMatchup != null)
|
||||||
|
{
|
||||||
|
if (me.ParentMatchup.Id == m.Id)
|
||||||
|
{
|
||||||
|
me.TeamCompeting = m.Winner;
|
||||||
|
GlobalConfig.Connection.UpdateMatchup(rm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LoadMatchups((int)roundDropDown.SelectedItem);
|
LoadMatchups((int)roundDropDown.SelectedItem);
|
||||||
|
|
||||||
|
GlobalConfig.Connection.UpdateMatchup(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user