|
|
|
@ -37,46 +37,49 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
|
|
|
|
|
|
|
|
|
|
public override IQueryable<IoTApi> Query(PagedListModel<EditPlatformIoTApiModel> model, IQueryable<IoTApi> query)
|
|
|
|
|
{
|
|
|
|
|
ViewData.SelectList(o => model.Query.ProductId, () => this._ajax.GetIoTProduct(model.Query.ProductId).SelectList());
|
|
|
|
|
ViewData.SelectList(o => model.Query.IoTProductId, () => this._ajax.GetIoTProduct(model.Query.IoTProductId).SelectList());
|
|
|
|
|
return query
|
|
|
|
|
.WhereIf(model.Query.CategoryId.HasValue, o => o.Product.IoTProductCategoryId == model.Query.CategoryId.Value)
|
|
|
|
|
.WhereIf(model.Query.ProductId.HasValue, o => o.IoTProductId == model.Query.ProductId.Value)
|
|
|
|
|
.WhereIf(model.Query.IoTProductCategoryId.HasValue, o => o.Product.IoTProductCategoryId == model.Query.IoTProductCategoryId.Value)
|
|
|
|
|
.WhereIf(model.Query.IoTProductId.HasValue, o => o.IoTProductId == model.Query.IoTProductId.Value)
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.Query.Path), o => o.Path.Contains(model.Query.Path))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.Query.Command), o => o.Command.Contains(model.Query.Command))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(model.Query.Method), o => o.Method.Contains(model.Query.Method));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void EntityToModel(IoTApi entity, EditPlatformIoTApiModel model)
|
|
|
|
|
{
|
|
|
|
|
model.IoTProductCategoryId = entity?.Product?.IoTProductCategoryId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ToDisplayModel(IoTApi entity, EditPlatformIoTApiModel model)
|
|
|
|
|
{
|
|
|
|
|
model.CategoryId = entity?.Product?.IoTProductCategoryId;
|
|
|
|
|
if (entity != null)
|
|
|
|
|
{
|
|
|
|
|
ViewData.Add(model.ProductId.Value, entity.Product.Name);
|
|
|
|
|
ViewData.Add(model.IoTProductId.Value, entity.Product?.Name);
|
|
|
|
|
}
|
|
|
|
|
if (model.CategoryId.HasValue)
|
|
|
|
|
if (model.IoTProductCategoryId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var name = this._categoryRepo.ReadOnlyTable()
|
|
|
|
|
.Where(o => o.ParentId != null)
|
|
|
|
|
.Where(o => o.Left <= entity.Product.IoTProductCategory.Left && o.Right >= entity.Product.IoTProductCategory.Right)
|
|
|
|
|
.ToList()
|
|
|
|
|
.ToTree()
|
|
|
|
|
.FirstOrDefault(o => o.Id == model.CategoryId.Value)?.GetDisplayName();
|
|
|
|
|
ViewData.Add(model.CategoryId.Value, name);
|
|
|
|
|
.FirstOrDefault(o => o.Id == model.IoTProductCategoryId.Value)?.GetDisplayName();
|
|
|
|
|
ViewData.Add(model.IoTProductCategoryId.Value, name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ToEditModel(IoTApi entity, EditPlatformIoTApiModel model)
|
|
|
|
|
{
|
|
|
|
|
model.CategoryId = entity?.Product?.IoTProductCategoryId;
|
|
|
|
|
ViewData.SelectList(o => model.CategoryId, () => this._ajax.GetIoTProductCategory(model.CategoryId).SelectList());
|
|
|
|
|
if (model.CategoryId.HasValue)
|
|
|
|
|
ViewData.SelectList(o => model.IoTProductCategoryId, () => this._ajax.GetIoTProductCategory(model.IoTProductCategoryId).SelectList());
|
|
|
|
|
if (model.IoTProductCategoryId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProductByCategory(model.CategoryId.Value, model.ProductId).SelectList());
|
|
|
|
|
ViewData.SelectList(o => model.IoTProductId, () => this._ajax.GetIoTProductByCategory(model.IoTProductCategoryId.Value, model.IoTProductId).SelectList());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ViewData.Add(model.ProductId, entity?.Product?.Name);
|
|
|
|
|
ViewData.Add(model.IoTProductId, entity?.Product?.Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|