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.
69 lines
2.6 KiB
69 lines
2.6 KiB
using Infrastructure.Application;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Infrastructure.Web.Mvc;
|
|
using IoT.Shared.Application.Domain.Entities;
|
|
using IoT.Shared.Application.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace IoT.Shared.Areas.IoTCenter.Controlls
|
|
{
|
|
[Authorize]
|
|
[ApiController]
|
|
[Route("IoTCenter/[controller]/[action]")]
|
|
[Area("IoTCenter")]
|
|
[ControllerScope(ControllerScopeType.Platform)]
|
|
public class IoTGatewayController : SharedController<IoTGateway, EditNodeModel>
|
|
{
|
|
public IoTGatewayController(IRepository<IoTGateway> repo, IServiceProvider sp) : base(repo, sp)
|
|
{
|
|
}
|
|
|
|
public override IQueryable<IoTGateway> Query(PagedListModel<EditNodeModel> model, IQueryable<IoTGateway> query)
|
|
{
|
|
return base.Query(model, query)
|
|
//.WhereIf(!string.IsNullOrEmpty(model.Query.OrganName), o => o.OrganNodes.Any(o => o.Organ.Name.Contains(model.Query.OrganName)))
|
|
//.WhereIf(!string.IsNullOrEmpty(model.Query.CategoryName), o => o.CategoryNodes.Any(o => o.Category.Name.Contains(model.Query.CategoryName)))
|
|
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
|
|
.WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number))
|
|
.WhereIf(!string.IsNullOrEmpty(model.Query.Version), o => o.Version.Contains(model.Query.Version))
|
|
.WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value)
|
|
.WhereIf(model.Query.Hidden.HasValue, o => o.Hidden == model.Query.Hidden.Value);
|
|
}
|
|
|
|
public override string GetNodeNumber(EditNodeModel model)
|
|
{
|
|
return model.Number;
|
|
}
|
|
|
|
public override IActionResult Delete(List<Guid> list)
|
|
{
|
|
if (this.isPlatform)
|
|
{
|
|
foreach (var id in list)
|
|
{
|
|
try
|
|
{
|
|
this.Repo.Delete(this.Repo.Table().FirstOrDefault(o => o.Id == id));
|
|
this.Repo.SaveChanges();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ex.PrintStack();
|
|
return Error(ex.Message);
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
return base.Delete(list);
|
|
}
|
|
}
|
|
}
|
|
}
|