diff --git a/Sources/BowlingApi/BowlingApi.csproj b/Sources/BowlingApi/BowlingApi.csproj
index 9f640c5..46c83c3 100644
--- a/Sources/BowlingApi/BowlingApi.csproj
+++ b/Sources/BowlingApi/BowlingApi.csproj
@@ -12,6 +12,13 @@
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
@@ -20,4 +27,19 @@
+<<<<<<< HEAD
+=======
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+>>>>>>> origine/Branche1
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 5ba9eec..4173911 100644
--- a/Sources/BowlingApi/Program.cs
+++ b/Sources/BowlingApi/Program.cs
@@ -27,6 +27,8 @@ builder.Services.AddDbContext(options =>
});
builder.Services.AddScoped();
+builder.Services.AddScoped();
+builder.Services.AddScoped();
//configure Logger
builder.Services.AddLogging(configure =>
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/DTOs/EquipeDTO.cs b/Sources/DTOs/EquipeDTO.cs
index e30f2ac..7972224 100644
--- a/Sources/DTOs/EquipeDTO.cs
+++ b/Sources/DTOs/EquipeDTO.cs
@@ -16,7 +16,6 @@ namespace DTOs
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 53da26c..4f93c80 100644
--- a/Sources/DTOs/FrameDTO.cs
+++ b/Sources/DTOs/FrameDTO.cs
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-namespace DTOs
+namespace BowlingEF.Entities
{
///
/// Classe de gestion des frames
@@ -9,9 +9,13 @@ namespace DTOs
public class FrameDTO
{
#region Properties
+
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; }
diff --git a/Sources/DTOs/JoueurDTO.cs b/Sources/DTOs/JoueurDTO.cs
index 012f3f0..89f77b8 100644
--- a/Sources/DTOs/JoueurDTO.cs
+++ b/Sources/DTOs/JoueurDTO.cs
@@ -12,8 +12,6 @@ namespace DTOs
[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 a6761f1..042ac37 100644
--- a/Sources/DTOs/PartieDTO.cs
+++ b/Sources/DTOs/PartieDTO.cs
@@ -14,16 +14,14 @@ namespace DTOs
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/GraphQL Project/bowling.db b/Sources/GraphQL Project/bowling.db
index f8b7759..ebb188c 100644
Binary files a/Sources/GraphQL Project/bowling.db and b/Sources/GraphQL Project/bowling.db differ
diff --git a/Sources/Mapper/PartieProfile.cs b/Sources/Mapper/PartieProfile.cs
index 2826969..3305846 100644
--- a/Sources/Mapper/PartieProfile.cs
+++ b/Sources/Mapper/PartieProfile.cs
@@ -8,6 +8,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