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.
42 lines
1.3 KiB
42 lines
1.3 KiB
using System;
|
|
using System.Linq;
|
|
using Application.Domain.Entities;
|
|
using Infrastructure.Data;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace IoTNode.Controllers
|
|
{
|
|
[Authorize]
|
|
public class DeviceController : Controller
|
|
{
|
|
private readonly IConfiguration _configuration;
|
|
private readonly IRepository<Node> _nodeRepo;
|
|
private readonly IRepository<Device> _deviceRepo;
|
|
|
|
public DeviceController(IConfiguration configuration, IRepository<Node> nodeRepo, IRepository<Device> deviceRepo)
|
|
{
|
|
this._configuration = configuration;
|
|
this._nodeRepo = nodeRepo;
|
|
this._deviceRepo = deviceRepo;
|
|
}
|
|
|
|
public IActionResult Index(Guid id)
|
|
{
|
|
var model = this._nodeRepo.ReadOnlyTable().FirstOrDefault(o => o.Id == id);
|
|
return View(model);
|
|
}
|
|
|
|
public IActionResult Details(Guid id)
|
|
{
|
|
var model = this._deviceRepo.ReadOnlyTable()
|
|
.Include(o => o.Node)
|
|
.Include(o => o.Data)
|
|
.Include(o => o.Apis).ThenInclude(o => o.Parameters)
|
|
.FirstOrDefault(o => o.Id == id);
|
|
return View(model);
|
|
}
|
|
}
|
|
} |