You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
61 lines
1.7 KiB
using Application.Domain.Entities;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
|
|
namespace IoTCenter.Api.Controllers
|
|
{
|
|
[ApiVersion("1.0")]
|
|
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
|
[ApiController]
|
|
public class SceneController : ControllerBase
|
|
{
|
|
private readonly IRepository<Scene> _sceneRepo;
|
|
|
|
public SceneController(IRepository<Scene> sceneRepo)
|
|
{
|
|
this._sceneRepo = sceneRepo;
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult GetScenes()
|
|
{
|
|
try
|
|
{
|
|
var model = this._sceneRepo.ReadOnlyTable()
|
|
.Where(o => o.NodeId == null)
|
|
.OrderBy(o => o.DisplayOrder);
|
|
return Ok(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ex.PrintStack();
|
|
return Problem(ex.Message);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult GetScene([Required]Guid id)
|
|
{
|
|
try
|
|
{
|
|
var model = this._sceneRepo.ReadOnlyTable()
|
|
.Include(o => o.SceneCommands)
|
|
.Include(o => o.SceneTimers)
|
|
.Include(o => o.SceneTiggers)
|
|
.Where(o => o.Id == id)
|
|
.FirstOrDefault();
|
|
return Ok(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ex.PrintStack();
|
|
return Problem(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
} |