diff --git a/Sources/BowlingApi/BowlingApi.csproj b/Sources/BowlingApi/BowlingApi.csproj
index 64f00fb..7996562 100644
--- a/Sources/BowlingApi/BowlingApi.csproj
+++ b/Sources/BowlingApi/BowlingApi.csproj
@@ -7,9 +7,18 @@
11
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
@@ -18,6 +27,12 @@
+
+
+
+
+
+
PreserveNewest
diff --git a/Sources/BowlingApi/Controllers/PartieController.cs b/Sources/BowlingApi/Controllers/PartieController.cs
new file mode 100644
index 0000000..848d695
--- /dev/null
+++ b/Sources/BowlingApi/Controllers/PartieController.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using BowlingService;
+using BowlingService.Interfaces;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+namespace BowlingApi.Controllers
+{
+
+
+ [Route("api/[controller]")]
+ [ApiController]
+ public class PartieController : ControllerBase
+ {
+
+
+ private IpartieService _partieService;
+
+ public PartieController(IpartieService partieService)
+ {
+ _partieService = partieService;
+ }
+
+
+
+
+ // GET: api/Partie
+ [HttpGet]
+ public IActionResult Get()
+ {
+ var result = _partieService.GetAll().Result;
+ return Ok(result);
+ }
+
+ // GET: api/Partie/5
+ [HttpGet("{name}")]
+ public IActionResult Get(string name)
+ {
+ return Ok(_partieService.GetDataWithName(name));
+ }
+
+ // POST: api/Partie
+ [HttpPost]
+ public void Post([FromBody] string value)
+ {
+ }
+
+ // PUT: api/Partie/5
+ [HttpPut("{id}")]
+ public void Put(int id, [FromBody] string value)
+ {
+ }
+
+ // DELETE: api/Partie/5
+ [HttpDelete("{id}")]
+ public void Delete(int id)
+ {
+ }
+ }
+}
diff --git a/Sources/BowlingApi/Program.cs b/Sources/BowlingApi/Program.cs
index 2a009e5..fd44c1e 100644
--- a/Sources/BowlingApi/Program.cs
+++ b/Sources/BowlingApi/Program.cs
@@ -18,6 +18,8 @@ builder.Services.AddSwaggerGen();
builder.Services.AddAutoMapper(typeof(JoueurProfile));
builder.Services.AddScoped();
builder.Services.AddScoped();
+builder.Services.AddScoped();
+builder.Services.AddScoped();
var app = builder.Build();
diff --git a/Sources/BowlingApi/Properties/launchSettings.json b/Sources/BowlingApi/Properties/launchSettings.json
index ea7e601..018693f 100644
--- a/Sources/BowlingApi/Properties/launchSettings.json
+++ b/Sources/BowlingApi/Properties/launchSettings.json
@@ -1,4 +1,4 @@
-{
+{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
@@ -11,7 +11,6 @@
"profiles": {
"http": {
"commandName": "Project",
- "dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5229",
@@ -21,7 +20,6 @@
},
"https": {
"commandName": "Project",
- "dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7097;http://localhost:5229",
@@ -38,4 +36,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Sources/BowlingApi/bowling.db b/Sources/BowlingApi/bowling.db
index b257dc9..ebb188c 100644
Binary files a/Sources/BowlingApi/bowling.db and b/Sources/BowlingApi/bowling.db differ
diff --git a/Sources/BowlingApi/bowling.db-shm b/Sources/BowlingApi/bowling.db-shm
deleted file mode 100644
index 3f65a68..0000000
Binary files a/Sources/BowlingApi/bowling.db-shm and /dev/null differ
diff --git a/Sources/BowlingApi/bowling.db-wal b/Sources/BowlingApi/bowling.db-wal
deleted file mode 100644
index c2050de..0000000
Binary files a/Sources/BowlingApi/bowling.db-wal and /dev/null differ
diff --git a/Sources/BowlingRepository/Interface/IEquipeRepository.cs b/Sources/BowlingRepository/Interface/IEquipeRepository.cs
index c782472..c0d3ef9 100644
--- a/Sources/BowlingRepository/Interface/IEquipeRepository.cs
+++ b/Sources/BowlingRepository/Interface/IEquipeRepository.cs
@@ -1,4 +1,4 @@
-using BowlingEF.Entities;
+ using BowlingEF.Entities;
namespace BowlingRepository.Interface;
diff --git a/Sources/BowlingRepository/Interface/IpartieRepository.cs b/Sources/BowlingRepository/Interface/IpartieRepository.cs
new file mode 100644
index 0000000..9381a82
--- /dev/null
+++ b/Sources/BowlingRepository/Interface/IpartieRepository.cs
@@ -0,0 +1,17 @@
+using System;
+using BowlingEF.Entities;
+
+namespace BowlingRepository.Interface
+{
+ public interface IpartieRepository
+ {
+ public Task Add(PartieEntity _partie);
+ public Task Delete(PartieEntity _partie);
+ public Task Update(PartieEntity _partie);
+ public Task> GetAll();
+ public Task> GetAllWithDate(DateTime date);
+ public Task GetDataWithName(string nom);
+
+ }
+}
+
diff --git a/Sources/BowlingRepository/Interface/PartieRepository.cs b/Sources/BowlingRepository/Interface/PartieRepository.cs
new file mode 100644
index 0000000..43f8020
--- /dev/null
+++ b/Sources/BowlingRepository/Interface/PartieRepository.cs
@@ -0,0 +1,58 @@
+using System;
+using BowlingEF.Context;
+using BowlingEF.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace BowlingRepository.Interface
+{
+ public class PartieRepository:IpartieRepository
+ {
+ private readonly BowlingContext _context;
+ public PartieRepository()
+ {
+ _context = new BowlingContext();
+ }
+
+ public async Task Add(PartieEntity partie)
+ {
+ _context.Parties.Add( partie);
+ return await _context.SaveChangesAsync() > 0;
+
+
+ }
+
+ public async Task Delete(PartieEntity _partie)
+ {
+ using (var context = new BowlingContext())
+ {
+ PartieEntity entity = context.Parties.Find(_partie.Id);
+ context.Parties.Remove(entity);
+ return await context.SaveChangesAsync() > 0;
+ }
+ }
+
+
+
+ public async Task> GetAll()
+ {
+ return await _context.Parties.ToListAsync();
+ }
+
+ public Task> GetAllWithDate(DateTime date)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetDataWithName(string nom)
+ {
+ // return await _context.Parties.FirstOrDefaultAsync(n => n == nom);
+ throw new NotImplementedException();
+ }
+
+ public async Task Update(PartieEntity _partie)
+ {
+ return await _context.SaveChangesAsync() > 0;
+ }
+ }
+}
+
diff --git a/Sources/BowlingService/Interfaces/IPartieService.cs b/Sources/BowlingService/Interfaces/IPartieService.cs
new file mode 100644
index 0000000..4ce4816
--- /dev/null
+++ b/Sources/BowlingService/Interfaces/IPartieService.cs
@@ -0,0 +1,16 @@
+using System;
+using BowlingEF.Entities;
+
+namespace BowlingService.Interfaces
+{
+ public interface IpartieService
+ {
+ public Task Add(PartieEntity _partie);
+ public Task Delete(PartieEntity _partie);
+ public Task Update(PartieEntity _partie);
+ public Task> GetAll();
+ public Task> GetAllWithDate(DateTime date);
+ public Task GetDataWithName(string nom);
+ }
+}
+
diff --git a/Sources/BowlingService/Interfaces/PartieService.cs b/Sources/BowlingService/Interfaces/PartieService.cs
new file mode 100644
index 0000000..32ab1bb
--- /dev/null
+++ b/Sources/BowlingService/Interfaces/PartieService.cs
@@ -0,0 +1,98 @@
+using System;
+using AutoMapper;
+using BowlingEF.Context;
+using BowlingEF.Entities;
+using BowlingLib.Model;
+using BowlingRepository;
+using BowlingRepository.Interface;
+using Microsoft.EntityFrameworkCore;
+
+namespace BowlingService.Interfaces
+{
+ public class PartieService:IpartieService
+ {
+ private readonly IpartieRepository _IpartieRepository;
+
+ public PartieService(IpartieRepository ipartieRepository, IMapper mapper)
+ {
+ _IpartieRepository = ipartieRepository;
+ _mapper = mapper;
+ }
+
+ public PartieService()
+ {
+
+ }
+ private readonly IMapper _mapper;
+
+ public async Task Add(PartieDTO _partie)
+ {
+ bool result = false;
+ using (var context = new BowlingContext())
+ {
+ PartieEntity entity = _mapper.Map(_partie);
+ context.Parties.Add(entity);
+ try
+ {
+ var data = await context.SaveChangesAsync();
+ result = data == 1;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ throw;
+ }
+ }
+
+ return result;
+ }
+
+
+ public async Task Delete(PartieEntity _partie)
+ {
+ return await _IpartieRepository.Delete(_partie);
+ }
+
+ public async Task> GetAll()
+ {
+ List result = new List();
+ using (var context = new BowlingContext())
+ {
+ foreach (PartieEntity entity in await _IpartieRepository.GetAll())
+ {
+ JoueurDTO joueur = _mapper.Map(entity.Joueur);
+ List frames = new List();
+ foreach (FrameEntity frameEntity in entity.Frames)
+ {
+ FrameDTO frame = _mapper.Map(frameEntity);
+ frames.Add(frame);
+ }
+ result.Add(_mapper.Map(entity));
+ }
+ }
+ return result.OrderBy(item => item.Date).ToList();
+
+ }
+
+ public Task> GetAllWithDate(DateTime date)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetDataWithName(string nom)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task Update(PartieEntity _partie)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task Add(PartieEntity _partie)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
+
diff --git a/Sources/BowlingService/JoueurService.cs b/Sources/BowlingService/JoueurService.cs
index 20b57d6..72f4b1b 100644
--- a/Sources/BowlingService/JoueurService.cs
+++ b/Sources/BowlingService/JoueurService.cs
@@ -43,7 +43,7 @@ namespace BowlingService
Pseudo = _joueur.Pseudo,
};
- //Parcourt de la liste des parties d'un joueur
+ //Parcourt de la liste des parties d'un joueur DTA
for (int i = 0; i < _joueur.PartieDTO.Count; i++)
{
//Mapping entre les parties d'un joueur et les partieEntity d'une partieEntity
diff --git a/Sources/DTOs/EquipeDTO.cs b/Sources/DTOs/EquipeDTO.cs
index 18d129e..55d8567 100644
--- a/Sources/DTOs/EquipeDTO.cs
+++ b/Sources/DTOs/EquipeDTO.cs
@@ -16,7 +16,6 @@ namespace BowlingEF.Entities
public string Nom { get; set; }
public ICollection Joueurs { get; set; }
#endregion
-
#region Constructeurs
public EquipeDTO()
{
diff --git a/Sources/DTOs/FrameDTO.cs b/Sources/DTOs/FrameDTO.cs
index 377953a..c0ec75c 100644
--- a/Sources/DTOs/FrameDTO.cs
+++ b/Sources/DTOs/FrameDTO.cs
@@ -9,17 +9,12 @@ namespace BowlingEF.Entities
public class FrameDTO
{
#region Properties
- [Key]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+
public long Id { get; set; }
- [Required]
public int Numero { get; set; }
- [Required]
public int Lancer1 { get; set; }
- [Required]
public int Lancer2 { get; set; }
public int Lancer3 { get; set; }
-
public PartieDTO Partie { get; set; }
#endregion
}
diff --git a/Sources/DTOs/JoueurDTO.cs b/Sources/DTOs/JoueurDTO.cs
index 8cf54ff..3df2f98 100644
--- a/Sources/DTOs/JoueurDTO.cs
+++ b/Sources/DTOs/JoueurDTO.cs
@@ -12,8 +12,6 @@ namespace BowlingEF.Entities
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
-
- [Required]
public string Pseudo { get; set; }
public ICollection PartieDTO { get; set; } = new List();
#endregion
diff --git a/Sources/DTOs/PartieDTO.cs b/Sources/DTOs/PartieDTO.cs
index 0386481..ba8b942 100644
--- a/Sources/DTOs/PartieDTO.cs
+++ b/Sources/DTOs/PartieDTO.cs
@@ -14,16 +14,14 @@ namespace BowlingEF.Entities
public class PartieDTO
{
#region Properties
- [Key]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+
public long Id { get; set; }
- [ForeignKey("JoueurForeignKey")]
public JoueurDTO Joueur { get; set; }
- [Required]
+
public DateTime Date { get; set; }
public ICollection FramesDTO { get; set; }
- [Required]
+
public int? Score { get; set; }
#endregion
diff --git a/Sources/Mapper/PartieProfile.cs b/Sources/Mapper/PartieProfile.cs
index 8b4ffab..ab78a99 100644
--- a/Sources/Mapper/PartieProfile.cs
+++ b/Sources/Mapper/PartieProfile.cs
@@ -7,6 +7,6 @@ public class PartieProfile:Profile
{
public PartieProfile()
{
- CreateMap();
+ CreateMap().ReverseMap();
}
}
\ No newline at end of file
diff --git a/Sources/Tests/BowlingAppUnitTest/BowlingAppUnitTest.sln b/Sources/Tests/BowlingAppUnitTest/BowlingAppUnitTest.sln
new file mode 100644
index 0000000..48ab595
--- /dev/null
+++ b/Sources/Tests/BowlingAppUnitTest/BowlingAppUnitTest.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 25.0.1704.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BowlingAppUnitTest", "BowlingAppUnitTest.csproj", "{6CE80C57-58B9-4481-B4EE-1DD615117D93}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6CE80C57-58B9-4481-B4EE-1DD615117D93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6CE80C57-58B9-4481-B4EE-1DD615117D93}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6CE80C57-58B9-4481-B4EE-1DD615117D93}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6CE80C57-58B9-4481-B4EE-1DD615117D93}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {977E7E9D-643B-4F31-B0F3-229032EB3B68}
+ EndGlobalSection
+EndGlobal