using Infrastructure.Data; using Infrastructure.Extensions; using Infrastructure.Web; using IoT.Shared.Application.Domain.Entities; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Platform.ViewModels; using System; using System.Linq; using System.Security.Claims; namespace Platform.Controllers { [Authorize] //[Device] [ApiExplorerSettings(IgnoreApi = true)] public class HomeController : Controller { private readonly IUserService _useService; private readonly IRepository _userRepo; private readonly IRepository _organRepo; private readonly IRepository _buildingRepo; public HomeController(IUserService userService,IRepository userRepo,IRepository organRepo,IRepository buildingRepo) { this._useService = userService; this._userRepo = userRepo; this._organRepo = organRepo; this._buildingRepo = buildingRepo; } public IActionResult Index() { return View(); } public IActionResult Product() { return View(); } public IActionResult Device() { return View(); } public IActionResult Organ() { return View(); } public IActionResult Nodes() { return View(); } public IActionResult Node() { return View(); } public string Mac(string id) { return Helper.Instance.MacEncrypt(id); } public IActionResult Index2(HomeModel model) { var userName = User.Identity.Name; model.Organs = this._userRepo.ReadOnlyTable() .SelectMany(o => o.OrganUsers) .Include(o=>o.Organ.Buildings) .ThenInclude(o=>o.Rooms) .ThenInclude(o=>o.RoomIoTGateways) .Where(o=>o.User.UserName==userName) .WhereIf(model.OrganId.HasValue, o => o.OrganId == model.OrganId.Value) .Select(o=>o.Organ) .ToList(); return View(model); } } }