From ff6ae7af932c70c9a202d81c9c9d7d0a794ba786 Mon Sep 17 00:00:00 2001 From: Ruya Arabaci Date: Wed, 9 Nov 2022 11:20:55 +0300 Subject: [PATCH 1/3] added indicator signal controller --- .../IIndicatorSignalService.cs | 12 +++++ .../IndicatorSignalService.cs | 12 +++++ .../Controllers/IndicatorSignalController.cs | 48 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs create mode 100644 Libraries/Hypance.Services/IndicatorSignals/IndicatorSignalService.cs create mode 100644 Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs diff --git a/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs b/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs new file mode 100644 index 0000000..941a18c --- /dev/null +++ b/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Hypance.Services.IndicatorSignals +{ + public interface IIndicatorSignal + { + + } +} \ No newline at end of file diff --git a/Libraries/Hypance.Services/IndicatorSignals/IndicatorSignalService.cs b/Libraries/Hypance.Services/IndicatorSignals/IndicatorSignalService.cs new file mode 100644 index 0000000..46a18f2 --- /dev/null +++ b/Libraries/Hypance.Services/IndicatorSignals/IndicatorSignalService.cs @@ -0,0 +1,12 @@ +using System; +using Hypance.Core.Domain.Symbols; +using Hypance.Data; +using Hypance.Data.DataProviders; + +namespace Hypance.Services.IndicatorSignals +{ + public class IndicatorSignalService : IIndicatorSignalService + { + + } +} \ No newline at end of file diff --git a/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs b/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs new file mode 100644 index 0000000..38b4461 --- /dev/null +++ b/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs @@ -0,0 +1,48 @@ +using Hypance.Core.Domain.Strategies; +using Hypance.Data; +using Microsoft.AspNetCore.Mvc; + +namespace Hypance.WebApi.Controllers +{ + [ApiController] + [Route("[controller]/[action]")] + public class IndicatorSignalController : Controller + { + private readonly IRepository _indicatorSignalRepository; + + public IndicatorSignalController(IRepository indicatorSignalRepository) + { + _indicatorSignalRepository = indicatorSignalRepository; + } + + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + [HttpGet("{id}")] + public string Get(int id) + { + return "value"; + } + + [HttpPost] + public IActionResult Post(IndicatorSignal indicatorSignal) + { + _indicatorSignalRepository.Add(indicatorSignal); + + return Ok(); + } + + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} \ No newline at end of file From 9ade06626e11f4e03c749ab0f4be4338934221bb Mon Sep 17 00:00:00 2001 From: Ruya Arabaci Date: Sat, 19 Nov 2022 21:23:35 +0300 Subject: [PATCH 2/3] added indicator signal --- .../IIndicatorSignalService.cs | 1 + .../Controllers/IndicatorSignalController.cs | 27 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs b/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs index 941a18c..faba09f 100644 --- a/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs +++ b/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading.Tasks; namespace Hypance.Services.IndicatorSignals diff --git a/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs b/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs index 38b4461..d5461f5 100644 --- a/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs +++ b/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs @@ -1,5 +1,6 @@ using Hypance.Core.Domain.Strategies; using Hypance.Data; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Hypance.WebApi.Controllers @@ -16,15 +17,19 @@ public IndicatorSignalController(IRepository indicatorSignalRep } [HttpGet] - public IEnumerable Get() + public IEnumerable GetAll() { - return new string[] { "value1", "value2" }; + var result = _indicatorSignalRepository.GetAll(); + + return result.Data; } [HttpGet("{id}")] - public string Get(int id) + public IndicatorSignal Get(int id) { - return "value"; + var model = _indicatorSignalRepository.Get(x => x.Id == id); + + return model.Data; } [HttpPost] @@ -35,14 +40,20 @@ public IActionResult Post(IndicatorSignal indicatorSignal) return Ok(); } - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) + [HttpPut] + public IActionResult Put(IndicatorSignal indicatorSignal) { + _indicatorSignalRepository.Update(indicatorSignal); + + return Ok(); } - [HttpDelete("{id}")] - public void Delete(int id) + [HttpDelete] + public IActionResult Delete(IndicatorSignal indicatorSignal) { + _indicatorSignalRepository.Delete(indicatorSignal); + + return Ok(); } } } \ No newline at end of file From cda8c4bb1d537ecd4b25e37788d526f0cd10380f Mon Sep 17 00:00:00 2001 From: Ruya Arabaci Date: Mon, 5 Dec 2022 21:25:27 +0300 Subject: [PATCH 3/3] added indicator signal service --- .../IIndicatorSignalService.cs | 2 +- .../Controllers/IndicatorSignalController.cs | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs b/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs index faba09f..df0467b 100644 --- a/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs +++ b/Libraries/Hypance.Services/IndicatorSignals/IIndicatorSignalService.cs @@ -6,7 +6,7 @@ namespace Hypance.Services.IndicatorSignals { - public interface IIndicatorSignal + public interface IIndicatorSignalService { } diff --git a/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs b/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs index d5461f5..2cc3468 100644 --- a/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs +++ b/Presenentation/Hypance.WebApi/Controllers/IndicatorSignalController.cs @@ -17,7 +17,7 @@ public IndicatorSignalController(IRepository indicatorSignalRep } [HttpGet] - public IEnumerable GetAll() + public List GetAll() { var result = _indicatorSignalRepository.GetAll(); @@ -28,32 +28,40 @@ public IEnumerable GetAll() public IndicatorSignal Get(int id) { var model = _indicatorSignalRepository.Get(x => x.Id == id); + if (model.Success) + return model.Data; - return model.Data; + return new IndicatorSignal(); } [HttpPost] public IActionResult Post(IndicatorSignal indicatorSignal) { - _indicatorSignalRepository.Add(indicatorSignal); + var result = _indicatorSignalRepository.Add(indicatorSignal); + if (result.Success) + return Ok(); - return Ok(); + return BadRequest(); } [HttpPut] public IActionResult Put(IndicatorSignal indicatorSignal) { - _indicatorSignalRepository.Update(indicatorSignal); + var result = _indicatorSignalRepository.Update(indicatorSignal); + if (result.Success) + return Ok(); - return Ok(); + return BadRequest(); } [HttpDelete] public IActionResult Delete(IndicatorSignal indicatorSignal) { - _indicatorSignalRepository.Delete(indicatorSignal); + var result = _indicatorSignalRepository.Delete(indicatorSignal); + if (result.Success) + return Ok(); - return Ok(); + return BadRequest(); } } } \ No newline at end of file