first commit

This commit is contained in:
motahhari
2025-10-31 20:21:22 +03:30
commit 60d20a2734
186 changed files with 15497 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using Microsoft.AspNetCore.Mvc;
using GreenHome.Application;
namespace GreenHome.Api.Controllers;
[ApiController]
[Route("api/[controller]")]
public class DevicesController : ControllerBase
{
private readonly IDeviceService deviceService;
public DevicesController(IDeviceService deviceService)
{
this.deviceService = deviceService;
}
[HttpGet]
public async Task<ActionResult<IReadOnlyList<DeviceDto>>> GetAll(CancellationToken cancellationToken)
{
var result = await deviceService.ListAsync(cancellationToken);
return Ok(result);
}
[HttpGet("CheckDevice")]
public async Task<ActionResult<IReadOnlyList<DeviceDto>>> CheckDevice(string deviceName,CancellationToken cancellationToken)
{
var result = await deviceService.GetDeviceId(deviceName,cancellationToken);
return Ok(result);
}
[HttpPost]
public async Task<ActionResult<int>> Create(DeviceDto dto, CancellationToken cancellationToken)
{
var id = await deviceService.AddDeviceAsync(dto, cancellationToken);
return Ok(id);
}
}