using Application.Domain.Entities; using Infrastructure.Application.Services.Settings; using Infrastructure.Data; using Infrastructure.Extensions; using Infrastructure.Web; using IoT.Shared.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Linq; namespace IoTNode.Controllers { //[Device] public class HomeController : BaseController { private readonly IRepository _iotGatewayRepo; private readonly IoTNodeClient _ioTNodeClient; public HomeController(IRepository iotGatewayRepo,IoTNodeClient ioTNodeClient) { this._iotGatewayRepo = iotGatewayRepo; this._ioTNodeClient = ioTNodeClient; } [Authorize] public IActionResult Index() { return View(); } public IActionResult IndexData() { var model = this._iotGatewayRepo.ReadOnlyTable() .Include(o => o.Devices) .ThenInclude(o => o.IoTProduct) .FirstOrDefault(); return Json(model); } public IActionResult Upload() { this._ioTNodeClient.OnConnected(); return RedirectTo(); } public IActionResult GetVersion() { return Content(Helper.Instance.GetVersion()); } } }