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.
51 lines
1.6 KiB
51 lines
1.6 KiB
using Application.Domain.Entities;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Web;
|
|
using IoT.Shared.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace IoTNode.Controllers
|
|
{
|
|
//[Device]
|
|
public class HomeController : BaseController
|
|
{
|
|
private readonly IRepository<Node> _nodeRepo;
|
|
private readonly IRepository<Scene> _sceneRepo;
|
|
private readonly IoTNodeClient _ioTNodeClient;
|
|
|
|
public HomeController(IRepository<Node> nodeRepo, IRepository<Scene> sceneRepo,IoTNodeClient ioTNodeClient)
|
|
{
|
|
this._nodeRepo = nodeRepo;
|
|
this._sceneRepo = sceneRepo;
|
|
this._ioTNodeClient = ioTNodeClient;
|
|
}
|
|
|
|
[Authorize]
|
|
public IActionResult Index()
|
|
{
|
|
var model = this._nodeRepo.ReadOnlyTable().Include(o => o.Devices).ThenInclude(o => o.Product).FirstOrDefault();
|
|
return View(model);
|
|
}
|
|
|
|
public IActionResult Scenes()
|
|
{
|
|
var model = this._sceneRepo.ReadOnlyTable()
|
|
.Include(o => o.SceneTimers)
|
|
.Include(o => o.SceneTiggers)
|
|
.Include(o => o.SceneCommands).ThenInclude(o=>o.Command).ThenInclude(o=>o.Device)
|
|
.Include(o=>o.SceneCommands).ThenInclude(o=>o.Command).ThenInclude(o=>o.Api)
|
|
.ToList();
|
|
return View(model);
|
|
}
|
|
|
|
public IActionResult Upload()
|
|
{
|
|
this._ioTNodeClient.OnConnected();
|
|
return RedirectTo();
|
|
}
|
|
}
|
|
} |