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.
iot/projects/IoTNode/Controllers/HomeController.cs

40 lines
1.1 KiB

using Application.Domain.Entities;
using Infrastructure.Data;
using Infrastructure.Web;
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<Device> _deviceRepo;
public HomeController(IRepository<Node> nodeRepo, IRepository<Device> deviceRepo)
{
this._nodeRepo = nodeRepo;
this._deviceRepo = deviceRepo;
}
[Authorize]
public IActionResult Index()
{
var model = this._deviceRepo.ReadOnlyTable().Include(o => o.Node).Include(o => o.Product).ToList();
return View(model);
}
public IActionResult GetNode(Guid id)
{
var model = this._nodeRepo.ReadOnlyTable()
.Include(o => o.Scenes)
.Include(o => o.Devices).ThenInclude(o => o.Data)
.FirstOrDefault(o => o.Id == id);
return Json(model);
}
}
}