mirror of
https://github.com/bvanroll/cs-oo-project.git
synced 2025-08-29 20:12:40 +00:00
voila
This commit is contained in:
241
Online Gokkantoor/LogicLayer/General.cs
Normal file
241
Online Gokkantoor/LogicLayer/General.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using DataLaag;
|
||||
using DataLaag.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
using static DataLaag.Enums;
|
||||
|
||||
namespace LogicLayer
|
||||
{
|
||||
public class General
|
||||
{
|
||||
public List<Wedstrijden> wedstrijden { get; set; }
|
||||
public List<Persoon> personen { get; set; }
|
||||
public List<Keuze> keuzes { get; set; }
|
||||
|
||||
public General()
|
||||
{
|
||||
wedstrijden = new List<Wedstrijden>();
|
||||
try
|
||||
{
|
||||
personen = new List<Persoon>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("" + ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
keuzes = new List<Keuze>();
|
||||
}catch (Exception e)
|
||||
{
|
||||
throw new Exception("" + e);
|
||||
}
|
||||
Deserialize();
|
||||
}
|
||||
|
||||
public void Deserialize()
|
||||
{
|
||||
using (StreamReader file = File.OpenText(@"Gegevens\Keuzes.json"))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
keuzes = (List<Keuze>)serializer.Deserialize(file, typeof(List<Keuze>));
|
||||
|
||||
}
|
||||
using (StreamReader file = File.OpenText(@"Gegevens\Personen.json"))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
personen = (List<Persoon>)serializer.Deserialize(file, typeof(List<Persoon>));
|
||||
}
|
||||
using (StreamReader file = File.OpenText(@"Gegevens\Wedstrijden.json"))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
wedstrijden = (List<Wedstrijden>)serializer.Deserialize(file, typeof(List<Wedstrijden>));
|
||||
}
|
||||
wedstrijden = (wedstrijden == null) ? new List<Wedstrijden>() : wedstrijden;
|
||||
personen = (personen == null) ? new List<Persoon>() : personen;
|
||||
keuzes = (keuzes == null) ? new List<Keuze>() : keuzes;
|
||||
|
||||
}
|
||||
public void Serialize()
|
||||
{
|
||||
using (StreamWriter file = File.CreateText(@"Gegevens\Keuzes.json"))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
serializer.Serialize(file, keuzes);
|
||||
}
|
||||
using (StreamWriter file = File.CreateText(@"Gegevens\Personen.json"))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
serializer.Serialize(file, personen);
|
||||
}
|
||||
using (StreamWriter file = File.CreateText(@"Gegevens\Wedstrijden.json"))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
serializer.Serialize(file, wedstrijden);
|
||||
}
|
||||
}
|
||||
|
||||
public void PlaatsGok(int matchID, int persoonID, double inzet, string g)
|
||||
{
|
||||
try
|
||||
{
|
||||
Enum.TryParse(g, out Gokken gok);
|
||||
Keuze k = new Keuze(matchID, persoonID, inzet, gok);
|
||||
keuzes.Add(k);
|
||||
}catch(Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public void GebruikerToevoegen(string voornaam, string naam, string adres, string gsm)
|
||||
{
|
||||
Persoon p = new Persoon(0, "Voornaam", "Naam", "Adres", "Gsm", 0.00);
|
||||
try
|
||||
{
|
||||
p = new Persoon(personen[personen.Count - 1].persoon_ID + 1, voornaam, naam, adres, gsm, 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
p = new Persoon(0, voornaam, naam, adres, gsm, 0);
|
||||
Debug.WriteLine("probleem met id settings");
|
||||
}
|
||||
personen.Add(p);
|
||||
}
|
||||
|
||||
public void MaakVoorbeelden()
|
||||
{
|
||||
personen.Add(new Persoon(1, "john", "doe", "street", "048765656565", 0.15));
|
||||
wedstrijden.Add(new Wedstrijden(128, "belgie", "polen", 1, 0, 2.3, 3, 1.8));
|
||||
keuzes.Add(new Keuze(128, 1, 0.15, Gokken.Thuisploeg));
|
||||
}
|
||||
|
||||
public List<string> GetGebruikers()
|
||||
{
|
||||
List<string> lijst = new List<string>();
|
||||
if (personen != null) {
|
||||
foreach(Persoon p in personen)
|
||||
{
|
||||
lijst.Add(p.persoon_ID+":"+p.naam + " " + p.voorNaam);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lijst.Add("None");
|
||||
}
|
||||
return lijst;
|
||||
}
|
||||
|
||||
public List<string> GetWedstrijden()
|
||||
{
|
||||
List<string> temp = new List<string>();
|
||||
if (personen != null)
|
||||
{
|
||||
foreach (Wedstrijden w in wedstrijden)
|
||||
{
|
||||
temp.Add( w.thuisPloeg + " - " + w.uitPloeg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
temp.Add("None");
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
public List<string> GetGeldVerdubbeling(int ID)
|
||||
{
|
||||
List<string> lijst2 = new List<string>();
|
||||
if (personen != null)
|
||||
{
|
||||
foreach (Wedstrijden a in wedstrijden)
|
||||
{
|
||||
if(a.wedstrijd_ID == ID)
|
||||
{
|
||||
lijst2.Add(a.geldThuisPloeg + "");
|
||||
lijst2.Add(a.geldGelijk + "");
|
||||
lijst2.Add(a.geldUitPloeg + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lijst2.Add("None");
|
||||
lijst2.Add("None");
|
||||
lijst2.Add("None");
|
||||
}
|
||||
return lijst2;
|
||||
}
|
||||
|
||||
public int[] GetP_ID()
|
||||
{
|
||||
int[] p_ID = new int[personen.Count];
|
||||
int teller = 0;
|
||||
foreach (Persoon p in personen)
|
||||
{
|
||||
p_ID[teller] = p.persoon_ID;
|
||||
teller++;
|
||||
}
|
||||
return p_ID;
|
||||
}
|
||||
|
||||
public int[] GetW_ID()
|
||||
{
|
||||
int[] w_ID = new int[wedstrijden.Count];
|
||||
int teller = 0;
|
||||
foreach (Wedstrijden w in wedstrijden)
|
||||
{
|
||||
w_ID[teller] = w.wedstrijd_ID;
|
||||
teller++;
|
||||
}
|
||||
return w_ID;
|
||||
}
|
||||
|
||||
private Wedstrijden GetWedstrijd(int ID)
|
||||
{
|
||||
foreach(Wedstrijden w in wedstrijden)
|
||||
{
|
||||
if(w.wedstrijd_ID == ID)
|
||||
{
|
||||
return w;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public double GetWinst(int ID)
|
||||
{
|
||||
double winst = 0;
|
||||
foreach (Keuze k in keuzes)
|
||||
{
|
||||
if(k.speler_ID == ID)
|
||||
{
|
||||
Gokken g = k.gok;
|
||||
double temp = k.inzet;
|
||||
Wedstrijden w = GetWedstrijd(k.match_ID);
|
||||
Gokken uitKomst = w.GetWinnaar();
|
||||
if(uitKomst == g)
|
||||
{
|
||||
switch (uitKomst)
|
||||
{
|
||||
case Gokken.Gelijk:
|
||||
winst += temp * w.geldGelijk;
|
||||
break;
|
||||
case Gokken.Thuisploeg:
|
||||
winst += temp * w.geldThuisPloeg;
|
||||
break;
|
||||
case Gokken.Uitploeg:
|
||||
winst += temp * w.geldUitPloeg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return winst;
|
||||
}
|
||||
}
|
||||
}
|
35
Online Gokkantoor/LogicLayer/Keuze.cs
Normal file
35
Online Gokkantoor/LogicLayer/Keuze.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using DataLaag.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static DataLaag.Enums;
|
||||
|
||||
namespace LogicLayer
|
||||
{
|
||||
public class Keuze : IFKeuze
|
||||
{
|
||||
|
||||
public int match_ID { get; set; }
|
||||
public int speler_ID { get; set; }
|
||||
public double inzet { get; set; }
|
||||
public Gokken gok { get; set; } // thuis uit of gelijk
|
||||
|
||||
public Keuze(int match_ID, int speler_ID, double inzet, Gokken gok)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.match_ID = match_ID;
|
||||
this.speler_ID = speler_ID;
|
||||
this.inzet = inzet;
|
||||
this.gok = gok;
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
throw new Exception("keuze is niet gelukt:" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
63
Online Gokkantoor/LogicLayer/LogicLayer.csproj
Normal file
63
Online Gokkantoor/LogicLayer/LogicLayer.csproj
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{517C3448-BD87-4D62-9316-6BABBC9A9CFC}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LogicLayer</RootNamespace>
|
||||
<AssemblyName>LogicLayer</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="General.cs" />
|
||||
<Compile Include="Keuze.cs" />
|
||||
<Compile Include="Persoon.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Wedstrijden.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DataLaag\DataLaag.csproj">
|
||||
<Project>{ca62d8ea-2739-4c85-81b4-fba040592dae}</Project>
|
||||
<Name>DataLaag</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
41
Online Gokkantoor/LogicLayer/Persoon.cs
Normal file
41
Online Gokkantoor/LogicLayer/Persoon.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using DataLaag.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace LogicLayer
|
||||
{
|
||||
public class Persoon : IFPersoon
|
||||
{
|
||||
public int persoon_ID { get; set; }
|
||||
public string voorNaam { get; set; }
|
||||
public string naam { get; set; }
|
||||
public string adres { get; set; }
|
||||
public string gsm { get; set; }
|
||||
public double balans { get; set; }
|
||||
|
||||
|
||||
public Persoon(int persoon_ID, string voorNaam, string naam, string adres, string gsm, double balans)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.persoon_ID = persoon_ID;
|
||||
this.voorNaam = voorNaam;
|
||||
this.naam = naam;
|
||||
this.adres = adres;
|
||||
this.gsm = gsm;
|
||||
this.balans = balans;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Foutieve ingave: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
36
Online Gokkantoor/LogicLayer/Properties/AssemblyInfo.cs
Normal file
36
Online Gokkantoor/LogicLayer/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("LogicLayer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LogicLayer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("517c3448-bd87-4d62-9316-6babbc9a9cfc")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
48
Online Gokkantoor/LogicLayer/Wedstrijden.cs
Normal file
48
Online Gokkantoor/LogicLayer/Wedstrijden.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using DataLaag.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static DataLaag.Enums;
|
||||
|
||||
namespace LogicLayer
|
||||
{
|
||||
public class Wedstrijden : IFWedstrijden
|
||||
{
|
||||
public int wedstrijd_ID { get; set; }
|
||||
public string thuisPloeg { get; set; }
|
||||
public string uitPloeg { get; set; }
|
||||
public int score_ThuisPloeg { get; set; }
|
||||
public int score_UitPloeg { get; set; }
|
||||
public double geldThuisPloeg { get; set; }
|
||||
public double geldGelijk { get; set; }
|
||||
public double geldUitPloeg { get; set; }
|
||||
|
||||
|
||||
public Wedstrijden(int wedstrijd_ID, string thuisPloeg, string uitPloeg, int score_ThuisPloeg, int score_UitPloeg, double geldThuisPloeg, double geldGelijk, double geldUitPloeg)
|
||||
{
|
||||
this.wedstrijd_ID = wedstrijd_ID;
|
||||
this.thuisPloeg = thuisPloeg;
|
||||
this.uitPloeg = uitPloeg;
|
||||
this.score_ThuisPloeg = score_ThuisPloeg;
|
||||
this.score_UitPloeg = score_UitPloeg;
|
||||
this.geldThuisPloeg = geldThuisPloeg;
|
||||
this.geldGelijk = geldGelijk;
|
||||
this.geldUitPloeg = geldUitPloeg;
|
||||
}
|
||||
|
||||
public Gokken GetWinnaar()
|
||||
{
|
||||
if(score_ThuisPloeg > score_UitPloeg)
|
||||
{
|
||||
return Gokken.Thuisploeg;
|
||||
}else if(score_UitPloeg > score_ThuisPloeg)
|
||||
{
|
||||
return Gokken.Uitploeg;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Gokken.Gelijk;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
4
Online Gokkantoor/LogicLayer/packages.config
Normal file
4
Online Gokkantoor/LogicLayer/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
|
||||
</packages>
|
Reference in New Issue
Block a user