102 lines
2.6 KiB
C#
102 lines
2.6 KiB
C#
|
using API_SequentMicrosystems.Models;
|
|||
|
using API_SequentMicrosystems.Services;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
|||
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|||
|
|
|||
|
namespace API_SequentMicrosystems.Controllers
|
|||
|
{
|
|||
|
[Route("points")]
|
|||
|
[ApiController]
|
|||
|
public class PointsController : ControllerBase
|
|||
|
{
|
|||
|
private PointsService _PointsService;
|
|||
|
|
|||
|
public PointsController(PointsService _PS)
|
|||
|
{
|
|||
|
_PointsService = _PS;
|
|||
|
}
|
|||
|
|
|||
|
// GET: api/<PointsController>
|
|||
|
/// <summary>
|
|||
|
/// Get all saved points
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet]
|
|||
|
public List<PointsModel> Get()
|
|||
|
{
|
|||
|
return _PointsService.GetPoints();
|
|||
|
}
|
|||
|
|
|||
|
// GET api/<PointsController>/5
|
|||
|
/// <summary>
|
|||
|
/// Read points from first to specified number
|
|||
|
/// </summary>
|
|||
|
/// <param name="max">max readed points</param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet("{max}")]
|
|||
|
public List<PointsModel> Get(int max)
|
|||
|
{
|
|||
|
return _PointsService.GetPoints().Take(max).ToList();
|
|||
|
}
|
|||
|
|
|||
|
// GET api/<PointsController>/5/5
|
|||
|
/// <summary>
|
|||
|
/// Read points from and to specified points positions
|
|||
|
/// </summary>
|
|||
|
/// <param name="max"></param>
|
|||
|
/// <param name="start"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet("{max}/{start}")]
|
|||
|
public List<PointsModel> Get(int max, int start)
|
|||
|
{
|
|||
|
return _PointsService.GetPoints().Skip(start).Take(max).ToList();
|
|||
|
}
|
|||
|
|
|||
|
//DELETE api/points
|
|||
|
/// <summary>
|
|||
|
/// Delete saved points
|
|||
|
/// </summary>
|
|||
|
[HttpDelete]
|
|||
|
public void Delete()
|
|||
|
{
|
|||
|
_PointsService.DeletePoints();
|
|||
|
}
|
|||
|
|
|||
|
//GET api/points/save
|
|||
|
/// <summary>
|
|||
|
/// Save new point
|
|||
|
/// </summary>
|
|||
|
[HttpGet("save")]
|
|||
|
public void GetSave()
|
|||
|
{
|
|||
|
_PointsService.SavePoint();
|
|||
|
}
|
|||
|
|
|||
|
//GET api/points/save/300
|
|||
|
/// <summary>
|
|||
|
/// Start timer to automatic saving points in specified interval
|
|||
|
/// </summary>
|
|||
|
/// <param name="sec"></param>
|
|||
|
[HttpGet("save/{sec}")]
|
|||
|
public void GetSaveSec(int sec)
|
|||
|
{
|
|||
|
//start autosave timer
|
|||
|
}
|
|||
|
|
|||
|
//GET api/points/save
|
|||
|
/// <summary>
|
|||
|
/// Stop timer for automatic save points
|
|||
|
/// </summary>
|
|||
|
[HttpDelete("save")]
|
|||
|
public void DeleteSaveSec()
|
|||
|
{
|
|||
|
//stop autosave timer
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|