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.
iot/projects/IoT.Shared/Areas/IoTCenter/Controlls/IoTProductController.cs

57 lines
2.3 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.Linq;
namespace IoT.Shared.Areas.IoTCenter.Controlls
{
/// <summary>
/// Defines the <see cref="IoTProductController" />.
/// </summary>
[Authorize]
[ApiController]
[Route("IoTCenter/[controller]/[action]")]
[Area("IoTCenter")]
[ControllerScope(ControllerScopeType.Platform)]
public class IoTProductController : SharedController<IoTProduct, EditProductModel>
{
/// <summary>
/// Defines the _ajax.
/// </summary>
private readonly AjaxBaseController _ajax;
/// <summary>
/// Initializes a new instance of the <see cref="IoTProductController"/> class.
/// </summary>
/// <param name="repo">The repo<see cref="IRepository{IoTProduct}"/>.</param>
/// <param name="ajax">The ajax<see cref="AjaxBaseController"/>.</param>
/// <param name="sp">The sp<see cref="IServiceProvider"/>.</param>
public IoTProductController(IRepository<IoTProduct> repo, AjaxBaseController ajax, IServiceProvider sp) : base(repo, sp)
{
this._ajax = ajax;
}
/// <summary>
/// The Query.
/// </summary>
/// <param name="model">The model<see cref="PagedListModel{EditProductModel}"/>.</param>
/// <param name="query">The query<see cref="IQueryable{IoTProduct}"/>.</param>
/// <returns>The <see cref="IQueryable{IoTProduct}"/>.</returns>
public override IQueryable<IoTProduct> Query(PagedListModel<EditProductModel> model, IQueryable<IoTProduct> query)
{
return base.Query(model, query)
.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.Path), o => o.Path.Contains(model.Query.Path))
.WhereIf(!string.IsNullOrEmpty(model.Query.ApiJson), o => o.ApiJson.Contains(model.Query.ApiJson))
.OrderBy(o => o.Number);
}
}
}