using Infrastructure.Application; using Infrastructure.Data; using Infrastructure.Extensions; using Infrastructure.Web.Mvc; using IoT.Shared.Application.Domain.Entities; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Platform.Application.Models; using Platform.Areas.IoTCenter.Controllers; using System.Linq; namespace Platform.Areas.UserCenter.Controllers { [Authorize] [ApiController] [Route("UserCenter/[controller]/[action]")] [Area("UserCenter")] [ControllerScope(ControllerScopeType.User)] public class UserOrganUserController : OrganUserController { public UserOrganUserController(IRepository repo, AjaxController ajax, IRepository organRepo) : base(repo, ajax, organRepo) { } public override IQueryable Query(PagedListModel model, IQueryable query) { var userName = User.Identity.Name; var organId = User.GetOrganId(); return base.Query(model, query) .WhereIf(organId.HasValue, o => o.Organ.Id == organId.Value) .Where(o => o.User.UserName == userName); } } }