using Application.Domain.Entities; using Infrastructure.Application; using Infrastructure.Data; using Infrastructure.Events; using Infrastructure.Web.Mvc; using IoTCenter.Application.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Linq; namespace IoTCenter.Areas.Admin.Controllers { [Authorize] [Area(nameof(Admin))] public class GlobalSceneController : CrudController, EditGlobalSceneModel, EditGlobalSceneModel> { private readonly IEventPublisher _publiser; public GlobalSceneController(IRepository repo, IEventPublisher publisher) : base(repo) { this._publiser = publisher; } public override IQueryable Query(PagedListModel model, IQueryable query) { return query.Where(o => o.NodeId == null); } public override void ToDisplayModel(Scene entity, EditGlobalSceneModel model) { base.ToDisplayModel(entity, model); } public override void OnInserted(Scene entity) { this._publiser.Publish(new EntityInsertedEvent(entity)); } public override void OnUpdated(Scene entity) { this._publiser.Publish(new EntityUpdatedEvent(entity)); } public override void OnDeleted(Scene entity) { this._publiser.Publish(new EntityDeletedEvent(entity)); } } }