diff --git a/Online Gokkantoor/Data/data.cs b/Online Gokkantoor/Data/data.cs index 9d3fbc8..a26f2a3 100644 --- a/Online Gokkantoor/Data/data.cs +++ b/Online Gokkantoor/Data/data.cs @@ -30,7 +30,7 @@ namespace Data } } catch (Exception e) { - + throw new Exception(e.Message); } return list; @@ -51,6 +51,7 @@ namespace Data } catch (Exception e) { + throw new Exception(e.Message); } return list; } @@ -68,6 +69,7 @@ namespace Data } } catch (Exception e) { + throw new Exception(e.Message); } return list; @@ -86,6 +88,7 @@ namespace Data } } catch (Exception e) { + throw new Exception(e.Message); } return list; diff --git a/Online Gokkantoor/Globals/Classes/Bet.cs b/Online Gokkantoor/Globals/Classes/Bet.cs index d273ac5..6c6de00 100644 --- a/Online Gokkantoor/Globals/Classes/Bet.cs +++ b/Online Gokkantoor/Globals/Classes/Bet.cs @@ -24,7 +24,7 @@ namespace Globals.classes public override bool Equals(object obj) { Bet b = (Bet)obj; - return b.game == this.game && this.person == b.person && b.cash == this.cash && this.ploeg == b.ploeg; + return this.Id == b.Id; } public override int GetHashCode() @@ -51,7 +51,7 @@ namespace Globals.classes public override string ToString() { - return person.ToString() + ":" + this.cash + "$ on " + this.game.ToString(); + return this.Id + ": " + person.ToString() + ":" + this.cash + "$ on " + this.game.ToString(); } } } diff --git a/Online Gokkantoor/Globals/Classes/Game.cs b/Online Gokkantoor/Globals/Classes/Game.cs index 297c118..adbbe7b 100644 --- a/Online Gokkantoor/Globals/Classes/Game.cs +++ b/Online Gokkantoor/Globals/Classes/Game.cs @@ -71,8 +71,9 @@ namespace Globals.classes public override bool Equals(object obj) { - Game g = (Game)obj; - return this.home == g.away; + + Game ga = (Game)obj; + return this.Id == ga.Id; } public override int GetHashCode() @@ -83,7 +84,7 @@ namespace Globals.classes public override string ToString() { - return this.home.ToString() + " / " + this.away.ToString(); + return this.Id + ": " + this.home.ToString() + " / " + this.away.ToString(); } } } diff --git a/Online Gokkantoor/Globals/Classes/Person.cs b/Online Gokkantoor/Globals/Classes/Person.cs index 6badab0..254731b 100644 --- a/Online Gokkantoor/Globals/Classes/Person.cs +++ b/Online Gokkantoor/Globals/Classes/Person.cs @@ -34,7 +34,7 @@ namespace Globals.classes public override string ToString() { - return this.name + " " + this.lastname; + return this.Id + ": " +this.name + " " + this.lastname; } } } diff --git a/Online Gokkantoor/Globals/Classes/Ploeg.cs b/Online Gokkantoor/Globals/Classes/Ploeg.cs index b0d5b2e..93722db 100644 --- a/Online Gokkantoor/Globals/Classes/Ploeg.cs +++ b/Online Gokkantoor/Globals/Classes/Ploeg.cs @@ -16,6 +16,12 @@ namespace Globals.classes { this.score = score; } + public Ploeg(string naam, int score, int Id) + { + this.score = score; + this.naam = naam; + this.Id = Id; + } public int Id { get; set; } public string naam { get; set; } @@ -24,6 +30,14 @@ namespace Globals.classes public override bool Equals(object obj) { + try + { + Ploeg te = (Ploeg)obj; + + } catch (Exception e) + { + return false; + } Ploeg t = (Ploeg)obj; return this.Id == t.Id; } @@ -40,7 +54,7 @@ namespace Globals.classes { score = ":" + this.score; } - return this.naam + score; + return this.Id + ": " + this.naam + score; } } diff --git a/Online Gokkantoor/Globals/Interfaces/ILogic.cs b/Online Gokkantoor/Globals/Interfaces/ILogic.cs index 38d44b7..fe0fda1 100644 --- a/Online Gokkantoor/Globals/Interfaces/ILogic.cs +++ b/Online Gokkantoor/Globals/Interfaces/ILogic.cs @@ -21,5 +21,9 @@ namespace Globals.Interfaces void save(); void updateGame(Game g); void updatePerson(Person p); + Person getPersonByString(string s); + Ploeg getPloegByString(string s); + Game getGameByString(string s); + Bet getBetByString(string s); } } diff --git a/Online Gokkantoor/Globals/main.cs b/Online Gokkantoor/Globals/main.cs index b2444b8..4bafc3a 100644 --- a/Online Gokkantoor/Globals/main.cs +++ b/Online Gokkantoor/Globals/main.cs @@ -6,4 +6,5 @@ namespace Globals { public enum state { draw, home, away }; } + } diff --git a/Online Gokkantoor/Gui/Admin.aspx.cs b/Online Gokkantoor/Gui/Admin.aspx.cs index 579f825..986c7ce 100644 --- a/Online Gokkantoor/Gui/Admin.aspx.cs +++ b/Online Gokkantoor/Gui/Admin.aspx.cs @@ -46,9 +46,9 @@ namespace Gui public void updateGame_Click(object sender, EventArgs args) { + logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; - IList boundList2 = (IList)listGames.DataSource; - HttpContext.Current.Application["currGame"] = boundList2[listGames.SelectedIndex]; + HttpContext.Current.Application["currGame"] = logic.getGameByString(listGames.SelectedValue); Server.Transfer("updateGame.aspx"); } diff --git a/Online Gokkantoor/Gui/Data/games.json b/Online Gokkantoor/Gui/Data/games.json index 0637a08..8441c69 100644 --- a/Online Gokkantoor/Gui/Data/games.json +++ b/Online Gokkantoor/Gui/Data/games.json @@ -1 +1 @@ -[] \ No newline at end of file +[{"date":"2015-01-01T00:00:00","Id":0 \ No newline at end of file diff --git a/Online Gokkantoor/Gui/Data/ploegen.json b/Online Gokkantoor/Gui/Data/ploegen.json index a7c555b..30d9bd6 100644 --- a/Online Gokkantoor/Gui/Data/ploegen.json +++ b/Online Gokkantoor/Gui/Data/ploegen.json @@ -1 +1 @@ -[{"Id":0,"naam":"bepkes","score":-2147483648,"scoreSet":false},{"Id":1,"naam":"selmakes","score":-2147483648,"scoreSet":false}] \ No newline at end of file +[{"Id":0,"naam":"jfkldjslkfj","score":-2147483648,"scoreSet":false},{"Id":1,"naam":"vdvdvd","score":-2147483648,"scoreSet":false}] \ No newline at end of file diff --git a/Online Gokkantoor/Gui/Login.aspx.cs b/Online Gokkantoor/Gui/Login.aspx.cs index 64d83aa..7973ed0 100644 --- a/Online Gokkantoor/Gui/Login.aspx.cs +++ b/Online Gokkantoor/Gui/Login.aspx.cs @@ -14,22 +14,35 @@ namespace Gui if (!Page.IsPostBack) { - LogicLayer logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; - lstUsers.DataSource = logic.persons; - lstUsers.DataBind(); + } } + protected override void OnInitComplete(EventArgs e) { base.OnInitComplete(e); + LogicLayer logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; + lstUsers.DataSource = logic.persons; + lstUsers.DataBind(); } protected override void OnPreLoad(EventArgs e) { base.OnPreLoad(e); + LogicLayer logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; + lstUsers.DataSource = logic.persons; + lstUsers.DataBind(); + } + protected override void OnLoadComplete(EventArgs e) + { + base.OnLoadComplete(e); + LogicLayer logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; + lstUsers.DataSource = logic.persons; + lstUsers.DataBind(); } public void Login_Click(object o, EventArgs e) { - HttpContext.Current.Application["user"] = lstUsers.SelectedItem; + LogicLayer logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; + HttpContext.Current.Application["user"] = logic.getPersonByString(lstUsers.SelectedValue); Server.Transfer("mainForm.aspx"); } diff --git a/Online Gokkantoor/Gui/addBet.aspx.cs b/Online Gokkantoor/Gui/addBet.aspx.cs index d5282f0..06b5a34 100644 --- a/Online Gokkantoor/Gui/addBet.aspx.cs +++ b/Online Gokkantoor/Gui/addBet.aspx.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Web; using System.Web.UI; +using Globals; using Globals.classes; using Logic; using static Globals.main; @@ -29,12 +30,8 @@ namespace Gui logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; try { - Game currGame = (Game)HttpContext.Current.Application["currGame"]; - - IList boundList2 = (IList)teams.DataSource; - state currPloeg = boundList2[teams.SelectedIndex]; - + state currPloeg = (state)Enum.Parse(typeof(state), teams.SelectedValue); double cash = double.Parse(amount.Text); Person currPers = (Person)HttpContext.Current.Application["user"]; if (cash > currPers.balance) diff --git a/Online Gokkantoor/Gui/addMatch.aspx.cs b/Online Gokkantoor/Gui/addMatch.aspx.cs index efcd426..7eaba39 100644 --- a/Online Gokkantoor/Gui/addMatch.aspx.cs +++ b/Online Gokkantoor/Gui/addMatch.aspx.cs @@ -12,6 +12,8 @@ namespace Gui public partial class addMatch : System.Web.UI.Page { LogicLayer logic; + static List p; + protected void Page_Load(object sender, EventArgs e) { @@ -19,24 +21,25 @@ namespace Gui { logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; dag.DataSource = Enumerable.Range(1, 31).ToArray(); - dag.DataBind(); maand.DataSource= Enumerable.Range(1, 12).ToArray(); - maand.DataBind(); jaar.DataSource = Enumerable.Range(2015, 10).ToArray(); - jaar.DataBind(); - ploeg1.DataSource = logic.ploegen; + p = logic.ploegen; + ploeg1.DataSource = p; + ploeg2.DataSource = p; ploeg1.DataBind(); - ploeg2.DataSource = logic.ploegen; ploeg2.DataBind(); + jaar.DataBind(); + maand.DataBind(); + dag.DataBind(); } } public void matchadd_Click(object sender, EventArgs e) { - IList p1l = (IList)ploeg1.DataSource; - IList p2l = (IList)ploeg2.DataSource; - Ploeg home = p1l[ploeg1.SelectedIndex]; - Ploeg away = p2l[ploeg2.SelectedIndex]; + + logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; + Ploeg home = logic.getPloegByString(ploeg1.SelectedValue); + Ploeg away = logic.getPloegByString(ploeg2.SelectedValue); int d, m, y = 0; if (home == away) { @@ -62,9 +65,6 @@ namespace Gui statusLabel.Text = "There was a problem parsing the data try again"; return; } - - - Game g = new Game(home, away, new DateTime(y, m, d)); logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; logic.addGame(g); diff --git a/Online Gokkantoor/Gui/addPloeg.aspx.cs b/Online Gokkantoor/Gui/addPloeg.aspx.cs index 6429a3d..0d82ac8 100644 --- a/Online Gokkantoor/Gui/addPloeg.aspx.cs +++ b/Online Gokkantoor/Gui/addPloeg.aspx.cs @@ -26,6 +26,7 @@ namespace Gui logic.addPloeg(p); logic.save(); HttpContext.Current.Application["logic"] = logic; + Response.Redirect("Admin.aspx"); } public void ret_Click(object sender, EventArgs e) { diff --git a/Online Gokkantoor/Gui/mainForm.aspx.cs b/Online Gokkantoor/Gui/mainForm.aspx.cs index 9cfb981..77f89f4 100644 --- a/Online Gokkantoor/Gui/mainForm.aspx.cs +++ b/Online Gokkantoor/Gui/mainForm.aspx.cs @@ -1,6 +1,8 @@ using System; +using System.Diagnostics; using System.Web; using System.Web.UI; +using Globals.classes; using Logic; namespace Gui @@ -17,6 +19,8 @@ namespace Gui logic = (LogicLayer)System.Web.HttpContext.Current.Application["logic"]; listGames.DataSource = logic.games; listGames.DataBind(); + Person test = (Globals.classes.Person)HttpContext.Current.Application["user"]; + Debug.Print(test.ToString()); } } diff --git a/Online Gokkantoor/Logic/LogicLayer.cs b/Online Gokkantoor/Logic/LogicLayer.cs index 51620a4..b7cfc8d 100644 --- a/Online Gokkantoor/Logic/LogicLayer.cs +++ b/Online Gokkantoor/Logic/LogicLayer.cs @@ -171,5 +171,44 @@ namespace Logic { persons[persons.FindIndex(e => e.Id == p.Id)] = p; } + + public Person getPersonByString(string s) + { + foreach (Person p in persons) + { + if (p.ToString() == s) + { + return p; + } + } + throw new Exception("No person by that personString found"); + } + + public Ploeg getPloegByString(string s) + { + foreach (Ploeg p in ploegen) + { + if (p.ToString() == s) return p; + } + throw new Exception("No ploeg by that ploegString was found"); + } + + public Game getGameByString(string s) + { + foreach (Game g in games) + { + if (g.ToString() == s) return g; + } + throw new Exception("No game by that gameString found"); + } + + public Bet getBetByString(string s) + { + foreach (Bet b in bets) + { + if (b.ToString() == s) return b; + } + throw new Exception("No bet by that betString was found"); + } } }