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.
31 lines
1.1 KiB
31 lines
1.1 KiB
using System.Linq;
|
|
using Application.Domain.Entities;
|
|
using Application.Models;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Infrastructure.Web.Mvc;
|
|
using IoTShared.Controllers;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace IoTCenter.Areas.Admin.Controllers
|
|
{
|
|
[Authorize]
|
|
[Area(nameof(Admin))]
|
|
public class ApiController : CrudController<Api, ApiSearchModel, EditApiModel, EditApiModel>
|
|
{
|
|
private readonly AjaxController _ajax;
|
|
|
|
public ApiController(IRepository<Api> repo, AjaxController ajax) : base(repo)
|
|
{
|
|
this._ajax = ajax;
|
|
}
|
|
|
|
public override IQueryable<Api> Query(ApiSearchModel model, IQueryable<Api> query)
|
|
{
|
|
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetProductSelectList(model.ProductId));
|
|
return query.WhereIf(model.ProductId.HasValue, o => o.ProductId == model.ProductId.Value)
|
|
.WhereIf(!string.IsNullOrEmpty(model.Keyword), o => o.Name.Contains(model.Keyword));
|
|
}
|
|
}
|
|
} |