|
|
|
@ -1,16 +1,10 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Application.Domain.Entities;
|
|
|
|
|
using Application.Models;
|
|
|
|
|
using Application.Services;
|
|
|
|
|
using Infrastructure.Application;
|
|
|
|
|
using Infrastructure.Data;
|
|
|
|
|
using Infrastructure.Web.Mvc;
|
|
|
|
|
using IoTShared;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
|
|
|
|
|
|
namespace IoTCenter.Areas.Admin.Controllers
|
|
|
|
|
{
|
|
|
|
@ -18,36 +12,8 @@ namespace IoTCenter.Areas.Admin.Controllers
|
|
|
|
|
[Area(nameof(Admin))]
|
|
|
|
|
public class NodeController : CrudController<Node, PagedListModel<EditNodeModel>, EditNodeModel, EditNodeModel>
|
|
|
|
|
{
|
|
|
|
|
private readonly IRepository<Node> _repo;
|
|
|
|
|
private readonly IHubContext<PageHub> _pageHubContext;
|
|
|
|
|
private readonly INodeService _nodeService;
|
|
|
|
|
|
|
|
|
|
public NodeController(IRepository<Node> repo, IHubContext<PageHub> pageHubContext, INodeService nodeService) : base(repo)
|
|
|
|
|
{
|
|
|
|
|
this._repo = repo;
|
|
|
|
|
this._pageHubContext = pageHubContext;
|
|
|
|
|
this._nodeService = nodeService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IActionResult Edit(EditNodeModel model)
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
this._pageHubContext.Clients.Group(model.Number).SendAsync(nameof(INodeService.EditNode), model);
|
|
|
|
|
return RedirectTo();
|
|
|
|
|
}
|
|
|
|
|
ModelState.AddModelError("", "服务器出现异常,请稍后重试");
|
|
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IActionResult Delete(List<Guid> list)
|
|
|
|
|
public NodeController(IRepository<Node> repo) : base(repo)
|
|
|
|
|
{
|
|
|
|
|
foreach (var id in list)
|
|
|
|
|
{
|
|
|
|
|
var model = this._repo.ReadOnlyTable().FirstOrDefault(o => o.Id == id);
|
|
|
|
|
this._pageHubContext.Clients.Group(model.Number).SendAsync(nameof(INodeService.DeleteNode), id);
|
|
|
|
|
}
|
|
|
|
|
return RedirectTo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|