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 { [Tags("Internal Saving Points (Recommended use only \"Actual\" endpoint for read all data at once. Saving points is not recomended)")] [Route("api/Points")] [ApiController] public class PointsController : ControllerBase { private PointsService _PointsService; public PointsController(PointsService _PS) { _PointsService = _PS; } // GET: api/ /// /// Get all saved points /// /// [HttpGet] public List Get() { return _PointsService.GetPoints().Take(1000).ToList(); ; } // GET api//5/5 /// /// Read points from and to specified points positions /// /// limit of returned points (Maximum 1000) /// id of start element /// [HttpGet("{start}/{limit}")] public List Get(int limit, int start) { if (limit > 1000) limit = 1000; return _PointsService.GetPoints(start, limit); } // POST api//5 /// /// Read points from and to specified points positions /// /// limit of returned points (Maximum 1000) /// start element /// [HttpPost("{limit}")] public List Post(int limit, [FromBody] PointsModel pm) { if (limit > 1000) limit = 1000; return _PointsService.GetPoints(limit, pm); } //GET api/Points/Actual /// /// Get Actual Point /// /// [HttpGet("Actual")] public PointsModel GetActual() { return _PointsService.GetPoint(); } // GET api//5 /// /// Read points from first to specified number /// /// [HttpGet("Count")] public int GetCount() { return _PointsService.GetPoints().Count; } //DELETE api/points /// /// Delete saved points /// [HttpDelete] public void Delete() { _PointsService.DeletePoints(); } //DELETE api/points /// /// Delete Specified saved point /// /// Point ID [HttpDelete("{id}")] public void Delete(int id) { _PointsService.DeletePoint(id); } //GET api/points/save /// /// Save new point /// [HttpGet("save")] public void GetSave() { _PointsService.SavePoint(); } //GET api/points/save/300 /// /// Start timer to automatic saving points in specified interval /// /// [HttpGet("AutoSave/{msec}")] public void GetSaveSec(int msec) { _PointsService.AutoSaveStart(msec); } //GET api/points/save /// /// Stop timer for automatic save points /// [HttpDelete("AutoSave")] public void DeleteSaveSec() { _PointsService.AutoSaveStop(); } } }