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.
84 lines
2.2 KiB
84 lines
2.2 KiB
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<User> _userRepo;
|
|
private readonly IRepository<Organ> _organRepo;
|
|
private readonly IRepository<Building> _buildingRepo;
|
|
|
|
public HomeController(IUserService userService,IRepository<User> userRepo,IRepository<Organ> organRepo,IRepository<Building> 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);
|
|
}
|
|
}
|
|
}
|