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.
39 lines
1.3 KiB
39 lines
1.3 KiB
using Application.Domain.Entities;
|
|
using Application.Models;
|
|
using Infrastructure.Application;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Infrastructure.Web.Mvc;
|
|
using IoT.Shared.Application.Models;
|
|
using IoTCenter.Services;
|
|
using IoTShared.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace IoTCenter.Areas.Admin.Controllers
|
|
{
|
|
[Authorize]
|
|
[Area(nameof(Admin))]
|
|
public class NodeController : CrudController<Node, PagedListModel<EditNodeModel>, EditNodeModel, EditNodeModel>
|
|
{
|
|
private readonly IHubContext<PageHub> _pageHubContext;
|
|
|
|
public NodeController(IRepository<Node> repo, IHubContext<PageHub> pageHubContext) : base(repo)
|
|
{
|
|
this._pageHubContext = pageHubContext;
|
|
}
|
|
|
|
public override IActionResult Edit(EditNodeModel model)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
var nodeDto = model.To<NodeDto>();
|
|
this._pageHubContext.Clients.Group(model.Number).SendAsync(Methods.ServerToClient, Methods.EditNodeRequest, nodeDto.ToJson(), null);
|
|
return RedirectTo();
|
|
}
|
|
ModelState.AddModelError("", "服务器出现异常,请稍后重试");
|
|
return View(model);
|
|
}
|
|
}
|
|
} |