From bee8ca06f43d0d5169620a6cec9ad80dd2f477cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Andr=C3=A9?= Date: Wed, 27 Nov 2019 14:06:22 +0100 Subject: [PATCH] Add a property "IsFavorite" for the drop zone. --- .../DropZoneService.cs | 5 +++-- .../Interface/IDropZoneService.cs | 6 ++--- .../AircraftRepository.cs | 5 +++++ .../DropZoneRepository.cs | 5 +++++ Back/skydiveLogs-api.Data/GearRepository.cs | 5 +++++ .../Interface/IRepository.cs | 1 + Back/skydiveLogs-api.Data/JumpRepository.cs | 5 +++++ .../JumpTypeRepository.cs | 5 +++++ Back/skydiveLogs-api.Model/DropZone.cs | 2 ++ .../Controllers/DropZoneController.cs | 4 ++-- .../Controllers/GearController.cs | 5 ++++- .../DataContract/DropZoneReq.cs | 22 +++++++++++++++---- .../DataContract/DropZoneResp.cs | 7 +++--- 13 files changed, 60 insertions(+), 17 deletions(-) diff --git a/Back/skydiveLogs-api.Business/DropZoneService.cs b/Back/skydiveLogs-api.Business/DropZoneService.cs index 23abe8d..6c7d8f5 100644 --- a/Back/skydiveLogs-api.Business/DropZoneService.cs +++ b/Back/skydiveLogs-api.Business/DropZoneService.cs @@ -35,9 +35,10 @@ namespace skydiveLogs_api.Business return _dropZoneRepository.GetById(id); } - public void UpdateDz(int id, DropZone dropZone) + public bool UpdateDz(int id, DropZone dropZone) { - throw new NotImplementedException(); + dropZone.Id = id; + return _dropZoneRepository.Update(dropZone); } private readonly IDropZoneRepository _dropZoneRepository; diff --git a/Back/skydiveLogs-api.Business/Interface/IDropZoneService.cs b/Back/skydiveLogs-api.Business/Interface/IDropZoneService.cs index 3e337be..6042116 100644 --- a/Back/skydiveLogs-api.Business/Interface/IDropZoneService.cs +++ b/Back/skydiveLogs-api.Business/Interface/IDropZoneService.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using skydiveLogs_api.Model; namespace skydiveLogs_api.Business.Interface @@ -13,7 +11,7 @@ namespace skydiveLogs_api.Business.Interface void DeleteDzById(int id); - void UpdateDz(int id, DropZone dropZone); + bool UpdateDz(int id, DropZone dropZone); void AddNewDz(DropZone dropZone); } diff --git a/Back/skydiveLogs-api.Data/AircraftRepository.cs b/Back/skydiveLogs-api.Data/AircraftRepository.cs index 8d638e9..d0c5692 100644 --- a/Back/skydiveLogs-api.Data/AircraftRepository.cs +++ b/Back/skydiveLogs-api.Data/AircraftRepository.cs @@ -27,6 +27,11 @@ namespace skydiveLogs_api.Data return _col.FindById(new BsonValue(id)); } + public bool Update(Aircraft aircraft) + { + return _col.Update(aircraft); + } + private readonly IDataProvider _dataProvider; private readonly LiteCollection _col; diff --git a/Back/skydiveLogs-api.Data/DropZoneRepository.cs b/Back/skydiveLogs-api.Data/DropZoneRepository.cs index 8528ead..333aaaf 100644 --- a/Back/skydiveLogs-api.Data/DropZoneRepository.cs +++ b/Back/skydiveLogs-api.Data/DropZoneRepository.cs @@ -27,6 +27,11 @@ namespace skydiveLogs_api.Data return _col.FindById(new BsonValue(id)); } + public bool Update(DropZone updatedDz) + { + return _col.Update(updatedDz); + } + private readonly IDataProvider _dataProvider; private readonly LiteCollection _col; diff --git a/Back/skydiveLogs-api.Data/GearRepository.cs b/Back/skydiveLogs-api.Data/GearRepository.cs index 297443a..6516c40 100644 --- a/Back/skydiveLogs-api.Data/GearRepository.cs +++ b/Back/skydiveLogs-api.Data/GearRepository.cs @@ -27,6 +27,11 @@ namespace skydiveLogs_api.Data return _col.FindById(new BsonValue(id)); } + public bool Update(Gear updatedGear) + { + return _col.Update(updatedGear); + } + private readonly IDataProvider _dataProvider; private readonly LiteCollection _col; diff --git a/Back/skydiveLogs-api.Data/Interface/IRepository.cs b/Back/skydiveLogs-api.Data/Interface/IRepository.cs index 0652f6a..8d01b37 100644 --- a/Back/skydiveLogs-api.Data/Interface/IRepository.cs +++ b/Back/skydiveLogs-api.Data/Interface/IRepository.cs @@ -8,5 +8,6 @@ namespace skydiveLogs_api.Data.Interface T GetById(int id); + bool Update(T updated); } } \ No newline at end of file diff --git a/Back/skydiveLogs-api.Data/JumpRepository.cs b/Back/skydiveLogs-api.Data/JumpRepository.cs index 51eda54..2388407 100644 --- a/Back/skydiveLogs-api.Data/JumpRepository.cs +++ b/Back/skydiveLogs-api.Data/JumpRepository.cs @@ -48,6 +48,11 @@ namespace skydiveLogs_api.Data return result; } + public bool Update(Jump updatedJump) + { + throw new System.NotImplementedException(); + } + private readonly IDataProvider _dataProvider; private readonly LiteCollection _col; diff --git a/Back/skydiveLogs-api.Data/JumpTypeRepository.cs b/Back/skydiveLogs-api.Data/JumpTypeRepository.cs index 2c6a25d..6416c8f 100644 --- a/Back/skydiveLogs-api.Data/JumpTypeRepository.cs +++ b/Back/skydiveLogs-api.Data/JumpTypeRepository.cs @@ -27,6 +27,11 @@ namespace skydiveLogs_api.Data return _col.FindById(new BsonValue(id)); } + public bool Update(JumpType updatedJumpType) + { + return _col.Update(updatedJumpType); + } + private readonly IDataProvider _dataProvider; private readonly LiteCollection _col; diff --git a/Back/skydiveLogs-api.Model/DropZone.cs b/Back/skydiveLogs-api.Model/DropZone.cs index 49b62d5..af08984 100644 --- a/Back/skydiveLogs-api.Model/DropZone.cs +++ b/Back/skydiveLogs-api.Model/DropZone.cs @@ -19,5 +19,7 @@ namespace skydiveLogs_api.Model public string Email { get; set; } public IEnumerable Type { get; set; } + + public bool IsFavorite { get; set; } } } diff --git a/Back/skydiveLogs-api/Controllers/DropZoneController.cs b/Back/skydiveLogs-api/Controllers/DropZoneController.cs index 952088d..efa91fa 100644 --- a/Back/skydiveLogs-api/Controllers/DropZoneController.cs +++ b/Back/skydiveLogs-api/Controllers/DropZoneController.cs @@ -50,9 +50,9 @@ namespace skydiveLogs_api.Controllers // PUT: api/DropZone/5 [HttpPut("{id}")] - public void Put(int id, [FromBody] DropZoneReq value) + public bool Put(int id, [FromBody] DropZoneReq value) { - _dropZoneService.UpdateDz(id, _mapper.Map(value)); + return _dropZoneService.UpdateDz(id, _mapper.Map(value)); } // DELETE: api/ApiWithActions/5 diff --git a/Back/skydiveLogs-api/Controllers/GearController.cs b/Back/skydiveLogs-api/Controllers/GearController.cs index 2093200..1c4bdd8 100644 --- a/Back/skydiveLogs-api/Controllers/GearController.cs +++ b/Back/skydiveLogs-api/Controllers/GearController.cs @@ -1,10 +1,13 @@ using System.Collections.Generic; -using AutoMapper; using Microsoft.AspNetCore.Mvc; + +using AutoMapper; + using skydiveLogs_api.Business.Interface; using skydiveLogs_api.DataContract; using skydiveLogs_api.Model; + namespace skydiveLogs_api.Controllers { [Route("api/[controller]")] diff --git a/Back/skydiveLogs-api/DataContract/DropZoneReq.cs b/Back/skydiveLogs-api/DataContract/DropZoneReq.cs index f814176..21bc24b 100644 --- a/Back/skydiveLogs-api/DataContract/DropZoneReq.cs +++ b/Back/skydiveLogs-api/DataContract/DropZoneReq.cs @@ -1,11 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; namespace skydiveLogs_api.DataContract { public class DropZoneReq { + public int Id { get; set; } + + public string Latitude { get; set; } + + public string Longitude { get; set; } + + public string Name { get; set; } + + public string Address { get; set; } + + public string Website { get; set; } + + public string Email { get; set; } + + public IEnumerable Type { get; set; } + + public bool IsFavorite { get; set; } } } diff --git a/Back/skydiveLogs-api/DataContract/DropZoneResp.cs b/Back/skydiveLogs-api/DataContract/DropZoneResp.cs index ec526ae..510badb 100644 --- a/Back/skydiveLogs-api/DataContract/DropZoneResp.cs +++ b/Back/skydiveLogs-api/DataContract/DropZoneResp.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; namespace skydiveLogs_api.DataContract { @@ -22,5 +19,7 @@ namespace skydiveLogs_api.DataContract public string Email { get; set; } public IEnumerable Type { get; set; } + + public bool IsFavorite { get; set; } } }