mirror of
https://github.com/bvanroll/cs-oo-project.git
synced 2025-08-29 20:12:40 +00:00
yup
This commit is contained in:
47
Online Gokkantoor/Logic/Logic.csproj
Normal file
47
Online Gokkantoor/Logic/Logic.csproj
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{82F1AF49-F9FA-42A1-BD3B-A37C36E340AD}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Logic</RootNamespace>
|
||||
<AssemblyName>Logic</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="LogicLayer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Data\Data.csproj">
|
||||
<Project>{46C1FC26-4A1F-43E4-8682-853010AB38AC}</Project>
|
||||
<Name>Data</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Globals\Globals.csproj">
|
||||
<Project>{3643BC50-8412-4C17-99E0-9D4BF7EDEB78}</Project>
|
||||
<Name>Globals</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
175
Online Gokkantoor/Logic/LogicLayer.cs
Normal file
175
Online Gokkantoor/Logic/LogicLayer.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using Globals.classes;
|
||||
using Globals.Interfaces;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
public class LogicLayer : ILogic
|
||||
{
|
||||
private dataLayer d;
|
||||
|
||||
public LogicLayer()
|
||||
{
|
||||
d = new dataLayer();
|
||||
|
||||
persons = d.getPersons();
|
||||
bets = d.getBets();
|
||||
ploegen = d.getPloegen();
|
||||
games = d.getGames();
|
||||
}
|
||||
|
||||
public LogicLayer(bool testMode)
|
||||
{
|
||||
d = new dataLayer();
|
||||
this.persons = new List<Person>();
|
||||
Person p = new Person("beppe", "vanrolleghem", "123straat", "04877777", 5);
|
||||
fixIds();
|
||||
this.persons.Add(p);
|
||||
}
|
||||
|
||||
public List<Person> persons { get ; set; }
|
||||
public List<Bet> bets { get; set; }
|
||||
public List<Ploeg> ploegen { get; set; }
|
||||
public List<Game> games { get; set; }
|
||||
|
||||
private void fixIds()
|
||||
{
|
||||
int i = 0;
|
||||
foreach(Person p in persons)
|
||||
{
|
||||
p.Id = i;
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
foreach(Bet b in bets)
|
||||
{
|
||||
b.Id = i;
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
foreach(Ploeg p in ploegen)
|
||||
{
|
||||
p.Id = i;
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
foreach(Game g in games)
|
||||
{
|
||||
g.Id = i;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void addBet(Bet b)
|
||||
{
|
||||
|
||||
bets.Add(b);
|
||||
fixIds();
|
||||
}
|
||||
|
||||
public void addGame(Game g)
|
||||
{
|
||||
games.Add(g);
|
||||
fixIds();
|
||||
}
|
||||
|
||||
public void addPerson(Person p)
|
||||
{
|
||||
persons.Add(p);
|
||||
fixIds();
|
||||
}
|
||||
|
||||
public void addPloeg(Ploeg p)
|
||||
{
|
||||
ploegen.Add(p);
|
||||
fixIds();
|
||||
}
|
||||
|
||||
public Bet getBet(int id)
|
||||
{
|
||||
foreach(Bet b in bets)
|
||||
{
|
||||
if (b.Id == id) return b;
|
||||
}
|
||||
throw new Exception("No bets found with that id");
|
||||
}
|
||||
|
||||
public Game getGame(int id)
|
||||
{
|
||||
foreach (Game b in games)
|
||||
{
|
||||
if (b.Id == id) return b;
|
||||
}
|
||||
throw new Exception("No bets found with that id");
|
||||
}
|
||||
|
||||
public Person getPerson(int id)
|
||||
{
|
||||
foreach (Person b in persons)
|
||||
{
|
||||
if (b.Id == id) return b;
|
||||
}
|
||||
throw new Exception("No bets found with that id");
|
||||
}
|
||||
|
||||
public Ploeg getPloeg(int id)
|
||||
{
|
||||
foreach (Ploeg b in ploegen)
|
||||
{
|
||||
if (b.Id == id) return b;
|
||||
}
|
||||
throw new Exception("No bets found with that id");
|
||||
}
|
||||
public void save()
|
||||
{
|
||||
fixIds();
|
||||
d.saveBets(bets);
|
||||
d.saveGames(games);
|
||||
d.savePersons(persons);
|
||||
d.savePloegen(ploegen);
|
||||
}
|
||||
|
||||
public void updateGame(Game g)
|
||||
{
|
||||
foreach (Game ga in games)
|
||||
{
|
||||
if (ga.Id == g.Id)
|
||||
{
|
||||
ga.home = g.home;
|
||||
ga.away = g.away;
|
||||
|
||||
}
|
||||
}
|
||||
updateBets();
|
||||
updateBalances();
|
||||
}
|
||||
|
||||
private void updateBets()
|
||||
{
|
||||
foreach (Bet b in bets)
|
||||
{
|
||||
Game g = games.Find(e => b.game.Id == e.Id);
|
||||
b.game = g;
|
||||
if (g.away.scoreSet && g.home.scoreSet) { b.finished = true; }
|
||||
}
|
||||
|
||||
}
|
||||
private void updateBalances()
|
||||
{
|
||||
foreach (Person p in persons)
|
||||
{
|
||||
foreach (Bet b in bets)
|
||||
{
|
||||
if (b.Equals(p) && b.finished) p.balance += b.getProfit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePerson(Person p)
|
||||
{
|
||||
persons[persons.FindIndex(e => e.Id == p.Id)] = p;
|
||||
}
|
||||
}
|
||||
}
|
26
Online Gokkantoor/Logic/Properties/AssemblyInfo.cs
Normal file
26
Online Gokkantoor/Logic/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("Logic")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("${AuthorCopyright}")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
Reference in New Issue
Block a user