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
{
///
/// Defines the .
///
[Authorize]
[ApiController]
[Route("IoTCenter/[controller]/[action]")]
[Area("IoTCenter")]
[ControllerScope(ControllerScopeType.Platform)]
public class IoTProductController : SharedController
{
///
/// Defines the _ajax.
///
private readonly AjaxBaseController _ajax;
///
/// Initializes a new instance of the class.
///
/// The repo.
/// The ajax.
/// The sp.
public IoTProductController(IRepository repo, AjaxBaseController ajax, IServiceProvider sp) : base(repo, sp)
{
this._ajax = ajax;
}
///
/// The Query.
///
/// The model.
/// The query.
/// The .
public override IQueryable Query(PagedListModel model, IQueryable 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);
}
}
}