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.
iot/projects/Platform/Areas/UserCenter/Controllers/OrganUserController.cs

49 lines
1.7 KiB

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 Microsoft.EntityFrameworkCore;
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.Platform)]
public class OrganUserController : CrudController<OrganUser, EditOrganUserModel>
{
private readonly AjaxController _ajax;
public OrganUserController(IRepository<OrganUser> repo, AjaxController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<OrganUser> Include(IQueryable<OrganUser> query)
{
return query
.Include(o => o.Organ)
.Include(o => o.User);
}
public override void ToDisplayModel(OrganUser entity, EditOrganUserModel model)
{
ViewData.Add(entity.OrganId, entity.Organ.Name);
ViewData.Add(entity.UserId, $"{entity.User.UserName}({entity.User.NickName})");
}
public override void ToEditModel(OrganUser entity, EditOrganUserModel model)
{
base.ToEditModel(entity, model);
this.ViewData.SelectList(o => model.OrganId, () => this._ajax.GetOrgan(model.OrganId).SelectList());
//this.ViewData.SelectList(o => model.UserId, () => this._ajax.GetUser(model.UserId).SelectList());
}
}
}