mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-14 01:25:38 -05:00
Add API to get most recent reading
This commit is contained in:
25
Weather/Service/Controllers/ReadingsController.cs
Normal file
25
Weather/Service/Controllers/ReadingsController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using ChrisKaczor.HomeMonitor.Weather.Models;
|
||||
using ChrisKaczor.HomeMonitor.Weather.Service.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ChrisKaczor.HomeMonitor.Weather.Service.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class ReadingsController : ControllerBase
|
||||
{
|
||||
private readonly Database _database;
|
||||
|
||||
public ReadingsController(Database database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
[HttpGet("recent")]
|
||||
public async Task<ActionResult<WeatherReading>> GetRecent()
|
||||
{
|
||||
return await _database.GetRecentReading();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ChrisKaczor.HomeMonitor.Weather.Service.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class ValuesController : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public ActionResult<IEnumerable<string>> Get()
|
||||
{
|
||||
return new[] { "value1", "value2" };
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user