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.
38 lines
1.5 KiB
38 lines
1.5 KiB
using Application.Domain.Entities;
|
|
using Application.Models;
|
|
using Infrastructure.Application;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Infrastructure.Web.Mvc;
|
|
using IoTShared.Controllers;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Linq;
|
|
|
|
namespace IoTCenter.Areas.Admin.Controllers
|
|
{
|
|
[Authorize]
|
|
[Area(nameof(Admin))]
|
|
public class GlobalSceneCommandController : CrudController<SceneCommand, PagedListModel<EditSceneCommandModel>, EditSceneCommandModel, EditSceneCommandModel>
|
|
{
|
|
private readonly AjaxController _ajax;
|
|
|
|
public GlobalSceneCommandController(IRepository<SceneCommand> repo, AjaxController ajax) : base(repo)
|
|
{
|
|
this._ajax = ajax;
|
|
}
|
|
|
|
public override IQueryable<SceneCommand> Include(IQueryable<SceneCommand> query)
|
|
{
|
|
return query.Include(o => o.Scene).ThenInclude(o => o.Node).Include(o => o.Command).ThenInclude(o => o.Device);
|
|
}
|
|
|
|
public override void ToModel(SceneCommand entity, EditSceneCommandModel model)
|
|
{
|
|
ViewData.SelectList(o => model.SceneId, () => this._ajax.GetGlobalSceneSelectList(model.SceneId));
|
|
ViewData.SelectList(o => model.NodeId, () => this._ajax.GetNodeSelectList(model.SceneId));
|
|
ViewData.SelectList(o => model.CommandId, () => this._ajax.GetCommandSelectList(model.NodeId.Value, model.CommandId), model.NodeId.HasValue);
|
|
}
|
|
}
|
|
} |