Commit 96ce9267 authored by NEBOIT Jean-Charles's avatar NEBOIT Jean-Charles
Browse files

TP2

parent 5bf518cf
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BusinessLayer</RootNamespace>
<AssemblyName>BusinessLayer</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -45,12 +45,16 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataAccessLayer\DataAccessLayer.csproj">
<Project>{70689c8b-c7fc-4928-b34f-c1962118bd63}</Project>
<Name>DataAccessLayer</Name>
</ProjectReference>
<ProjectReference Include="..\EntitiesLayer\EntitiesLayer.csproj">
<Project>{ba250fbe-da3e-43ef-b626-1c10c5d06d98}</Project>
<Name>EntitiesLayer</Name>
</ProjectReference>
<ProjectReference Include="..\StubDataAccessLayer\StubDataAccessLayer.csproj">
<Project>{5CB605E8-B932-437E-9BFC-4C055BE067D3}</Project>
<Project>{5cb605e8-b932-437e-9bfc-4c055be067d3}</Project>
<Name>StubDataAccessLayer</Name>
</ProjectReference>
</ItemGroup>
......
using EntitiesLayer;
using StubDataAccessLayer;
using DataAccessLayer;
using EntitiesLayer;
// using StubDataAccessLayer;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -14,8 +15,8 @@ namespace BusinessLayer
public ThronesTournamentManager()
{
DalManager = new DalManager(); // StubDataAccessLayer
//_dalManager = DalManager.Instance;
//DalManager = new DalManager(); // StubDataAccessLayer
DalManager = DalManager.Instance;
}
public List<String> HousesList()
......
using EntitiesLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccessLayer
{
public class DalManager
{
private static DalManager _instance;
private static readonly object padlock = new object();
private DataBaseBridge dataBaseBridge;
private DalManager()
{
dataBaseBridge = new SqlServer();
}
public static DalManager Instance
{
get
{
if (_instance == null)
{
lock (padlock)
{
if (_instance == null)
{
_instance = new DalManager();
}
}
}
return _instance;
}
}
public List<House> HousesList()
{
return dataBaseBridge.HousesList();
}
public List<House> HousesList(int sup)
{
return dataBaseBridge.HousesList(sup);
}
public List<Characteristics> CharactersCharacteristicsList()
{
return dataBaseBridge.CharactersCharacteristicsList();
}
public List<Character> CharactersList()
{
return dataBaseBridge.CharactersList();
}
public List<Territory> TerritoriesList()
{
return dataBaseBridge.TerritoriesList();
}
public List<Fight> FightsList()
{
return dataBaseBridge.FightsList();
}
public void addCharacter(Character character)
{
dataBaseBridge.addCharacter(character);
}
public void deleteCharacter(int id)
{
dataBaseBridge.deleteCharacter(id);
}
public void updateCharacter(Character character)
{
dataBaseBridge.updateCharacter(character);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccessLayer
{
public class DataAccessLayer
{
}
}
<?xml version="1.0" encoding="utf-8"?>
<?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>70689c8b-c7fc-4928-b34f-c1962118bd63</ProjectGuid>
<ProjectGuid>{70689C8B-C7FC-4928-B34F-C1962118BD63}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DataAccessLayer</RootNamespace>
......@@ -30,24 +30,26 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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"/>
<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="Class1.cs" />
<Compile Include="DalManager.cs" />
<Compile Include="DatabaseBridge.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlServer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EntitiesLayer\EntitiesLayer.csproj">
<Project>{ba250fbe-da3e-43ef-b626-1c10c5d06d98}</Project>
<Name>EntitiesLayer</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
\ No newline at end of file
using EntitiesLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccessLayer
{
interface DataBaseBridge
{
List<House> HousesList();
List<House> HousesList(int sup);
List<Character> CharactersList();
List<Characteristics> CharactersCharacteristicsList();
List<Territory> TerritoriesList();
List<Fight> FightsList();
void addCharacter(Character character);
void deleteCharacter(int id);
void updateCharacter(Character character);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EntitiesLayer;
using System.Data.SqlClient;
using System.Data;
namespace DataAccessLayer
{
class SqlServer : DataBaseBridge
{
private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"H:\\Documents\\ThronesTournamentConsole\\Base de donnée\\db.mdf\";Integrated Security=True;Connect Timeout=30";
private DataTable SelectByDataAdapter(string request)
{
DataTable results = new DataTable();
using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
{
SqlCommand sqlCommand = new SqlCommand(request, sqlConnection);
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
sqlDataAdapter.Fill(results);
}
return results;
}
public List<Character> CharactersList()
{
List<Character> res = new List<Character>();
DataTable dataTable = SelectByDataAdapter("Select * From Charater");
foreach (DataRow row in dataTable.Rows)
{
// Character character = new Character(Convert.ToInt32(row["Id"]), row["FirstName"].ToString(), row[");
// res.Add(character);
}
return res;
}
public List<Characteristics> CharactersCharacteristicsList()
{
List<Characteristics> res = new List<Characteristics>();
DataTable dataTable = SelectByDataAdapter("Select * From Character");
foreach (DataRow row in dataTable.Rows)
{
Characteristics characteristics = new Characteristics(Convert.ToUInt32(row["PV"]), (CharacterType)Convert.ToInt32(row["Type"]), Convert.ToInt32(row["Bravoury"]), Convert.ToInt32(row["Crazyness"]));
res.Add(characteristics);
}
return res;
}
public List<Fight> FightsList()
{
throw new NotImplementedException();
}
public List<House> HousesList()
{
List<House> res = new List<House>();
DataTable dataTable = SelectByDataAdapter("Select * From House");
foreach (DataRow row in dataTable.Rows)
{
House house = new House(Convert.ToInt32(row["Id"]), row["name"].ToString(), Convert.ToInt32(row["nbUnits"]));
res.Add(house);
}
return res;
}
public List<House> HousesList(int sup)
{
List<House> res = new List<House>();
DataTable dataTable = SelectByDataAdapter("Select * From House Where nbUnits >" + sup);
foreach (DataRow row in dataTable.Rows)
{
House house = new House(row[1].ToString());
res.Add(house);
}
return res;
}
public List<Territory> TerritoriesList()
{
throw new NotImplementedException();
}
public void addCharacter(Character character)
{
throw new NotImplementedException();
}
public void deleteCharacter(int id)
{
throw new NotImplementedException();
}
public void updateCharacter(Character character)
{
throw new NotImplementedException();
}
}
}
No preview for this file type
No preview for this file type
......@@ -44,17 +44,19 @@ namespace EntitiesLayer
public string FirstName { get; set; }
public string LastName { get; set; }
public Characteristics Characteristics { get; set; }
public House House { get; set; }
public Dictionary<Character, RelationshipType> RelationShips { get; set; }
public Character(int id, string firstName, string lastName, uint pv, CharacterType type, int bravoury, int crazyness)
public Character(int id, string firstName, string lastName, uint pv, CharacterType type, int bravoury, int crazyness, House house)
{
FirstName = firstName;
LastName = lastName;
Characteristics = new Characteristics(pv, type, bravoury, crazyness);
House = house;
RelationShips = new Dictionary<Character, RelationshipType>();
}
public Character(int id, string firstName, string lastName, uint pv, CharacterType type, int bravoury, int crazyness, Dictionary<Character, RelationshipType> relationShips) : this(id, firstName, lastName, pv, type, bravoury, crazyness)
public Character(int id, string firstName, string lastName, uint pv, CharacterType type, int bravoury, int crazyness, House house, Dictionary<Character, RelationshipType> relationShips) : this(id, firstName, lastName, pv, type, bravoury, crazyness, house)
{
RelationShips = relationShips;
}
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EntitiesLayer</RootNamespace>
<AssemblyName>EntitiesLayer</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......
......@@ -8,53 +8,14 @@ namespace EntitiesLayer
{
public class Fight : EntityObject
{
private House _challenger1;
private House _challenger2;
private House _winner;
public House Challenger1 { get; set; }
public House Challenger2 { get; set; }
public House Winner { get; set; }
public Fight(House challenger1, House challenger2)
{
Challenger1 = challenger1;
Challenger2 = challenger2;
}
public House Challenger1
{
get
{
return _challenger1;
}
set
{
_challenger1 = value;
}
}
public House Challenger2
{
get
{
return _challenger2;
}
set
{
_challenger2 = value;
}
}
public House Winner
{
get
{
return _winner;
}
set
{
_winner = value;
}
}
}
}
......@@ -9,34 +9,19 @@ namespace EntitiesLayer
public class House : EntityObject
{
public string Name { get; set; }
public List<Character> Housers { get; set; }
public int NbUnits { get; set; }
public House(string name)
{
Name = name;
Housers = new List<Character>();
NbUnits = 0;
}
public House(List<Character> housers, string name, int nbUnits)
public House(int id, string name, int nbUnits)
{
ID = id;
Name = name;
Housers = housers;
NbUnits = nbUnits;
}
public void AddHousers(List<Character> housers)
{
foreach(Character c in housers)
{
Housers.Add(c);
}
}
public override string ToString()
{
return "";
}
}
}
......@@ -8,5 +8,11 @@ namespace EntitiesLayer
{
public class War : EntityObject
{
public List<Fight> Battles { get; set; }
public War(List<Fight> battles)
{
Battles.AddRange(battles);
}
}
}
......@@ -12,7 +12,7 @@ namespace StubDataAccessLayer
private List<House> _housesList;
private List<Character> _characterList;
private List<Territory> _territoryList;
private War _war;
// private War _war;
public DalManager()
{
......@@ -31,11 +31,11 @@ namespace StubDataAccessLayer
_housesList.Add(Stark);
_housesList.Add(Targaryen);
Character Tyrion = new Character(0, "Tyrion", "Lannister", 100, CharacterType.TACTITIAN, 30, 20);
Character Cercei = new Character(1, "Cercei", "Lannister", 100, CharacterType.LEADER, 40, 90);
Character Arya = new Character(2, "Arya", "Stark", 100, CharacterType.WARRIOR, 70, 20);
Character Sansa = new Character(3, "Sansa", "Stark", 100, CharacterType.LOSER, 20, 40);
Character Daenerys = new Character(4, "Daenerys", "Targaryen", 100, CharacterType.LEADER, 100, 30);
Character Tyrion = new Character(0, "Tyrion", "Lannister", 100, CharacterType.TACTITIAN, 30, 20, Lannister);
Character Cercei = new Character(1, "Cercei", "Lannister", 100, CharacterType.LEADER, 40, 90, Lannister);
Character Arya = new Character(2, "Arya", "Stark", 100, CharacterType.WARRIOR, 70, 20, Stark);
Character Sansa = new Character(3, "Sansa", "Stark", 100, CharacterType.LOSER, 20, 40, Stark);
Character Daenerys = new Character(4, "Daenerys", "Targaryen", 100, CharacterType.LEADER, 100, 30, Targaryen);
_characterList.Add(Tyrion);
_characterList.Add(Cercei);
......@@ -43,10 +43,6 @@ namespace StubDataAccessLayer
_characterList.Add(Sansa);
_characterList.Add(Daenerys);
Lannister.AddHousers(new List<Character> { Tyrion , Cercei});
Stark.AddHousers(new List<Character> { Sansa , Arya});
Targaryen.AddHousers(new List<Character> { Daenerys });
Tyrion.AddRelatives(Cercei, RelationshipType.HATRED);
Sansa.AddRelatives(Tyrion, RelationshipType.FRIENDSHIP);
Arya.AddRelatives(Sansa, RelationshipType.LOVE);
......
......@@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StubDataAccessLayer</RootNamespace>
<AssemblyName>StubDataAccessLayer</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......
......@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiGOT", "WebApiGOT\WebA
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubDataAccessLayer", "StubDataAccessLayer\StubDataAccessLayer.csproj", "{5CB605E8-B932-437E-9BFC-4C055BE067D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccessLayer", "DataAccessLayer\DataAccessLayer.csproj", "{70689C8B-C7FC-4928-B34F-C1962118BD63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -39,6 +41,10 @@ Global
{5CB605E8-B932-437E-9BFC-4C055BE067D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CB605E8-B932-437E-9BFC-4C055BE067D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CB605E8-B932-437E-9BFC-4C055BE067D3}.Release|Any CPU.Build.0 = Release|Any CPU
{70689C8B-C7FC-4928-B34F-C1962118BD63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70689C8B-C7FC-4928-B34F-C1962118BD63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70689C8B-C7FC-4928-B34F-C1962118BD63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70689C8B-C7FC-4928-B34F-C1962118BD63}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<!--
Pour plus d'informations sur la configuration de votre application ASP.NET, visitez
https://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<appSettings></appSettings>
<appSettings/>
<!--
Pour obtenir une description des modifications de web.config, voir http://go.microsoft.com/fwlink/?LinkId=235367.
Les attributs suivants peuvent être définis dans la balise <httpRuntime>.
<system.Web>
<httpRuntime targetFramework="4.6.1" />
</system.Web>
-->
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
<