Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicator Signal Controller #57

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hypance.Services.IndicatorSignals
{
public interface IIndicatorSignalService
{

}
}
Original file line number Diff line number Diff line change
@@ -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
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Hypance.Core.Domain.Strategies;
using Hypance.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Hypance.WebApi.Controllers
{
[ApiController]
[Route("[controller]/[action]")]
public class IndicatorSignalController : Controller
{
private readonly IRepository<IndicatorSignal> _indicatorSignalRepository;

public IndicatorSignalController(IRepository<IndicatorSignal> indicatorSignalRepository)
{
_indicatorSignalRepository = indicatorSignalRepository;
}

[HttpGet]
public List<IndicatorSignal> GetAll()
{
var result = _indicatorSignalRepository.GetAll();

return result.Data;
}

[HttpGet("{id}")]
public IndicatorSignal Get(int id)
{
var model = _indicatorSignalRepository.Get(x => x.Id == id);
if (model.Success)
return model.Data;

return new IndicatorSignal();
}

[HttpPost]
public IActionResult Post(IndicatorSignal indicatorSignal)
{
var result = _indicatorSignalRepository.Add(indicatorSignal);
if (result.Success)
return Ok();

return BadRequest();
}

[HttpPut]
public IActionResult Put(IndicatorSignal indicatorSignal)
{
var result = _indicatorSignalRepository.Update(indicatorSignal);
if (result.Success)
return Ok();

return BadRequest();
}

[HttpDelete]
public IActionResult Delete(IndicatorSignal indicatorSignal)
{
var result = _indicatorSignalRepository.Delete(indicatorSignal);
if (result.Success)
return Ok();

return BadRequest();
}
}
}