2018-06-07 00:45:47 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Query
|
|
|
|
|
{
|
2018-10-28 15:08:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2018-06-07 00:45:47 +08:00
|
|
|
|
public class QueryRoleOption : PaginationOption
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RoleName { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-11-05 17:50:51 +08:00
|
|
|
|
public QueryData<object> RetrieveData()
|
2018-06-07 00:45:47 +08:00
|
|
|
|
{
|
|
|
|
|
// int limit, int offset, string name, string price, string sort, string order
|
2019-01-11 23:20:28 +08:00
|
|
|
|
var data = RoleHelper.Retrieves();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(RoleName))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.RoleName.Contains(RoleName));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(Description))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.Description.Contains(Description));
|
|
|
|
|
}
|
2018-11-05 17:50:51 +08:00
|
|
|
|
var ret = new QueryData<object>();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
ret.total = data.Count();
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.RoleName) : data.OrderByDescending(t => t.RoleName);
|
2018-11-05 17:50:51 +08:00
|
|
|
|
ret.rows = data.Skip(Offset).Take(Limit).Select(r => new { r.Id, r.RoleName, r.Description });
|
2018-06-07 00:45:47 +08:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-24 22:10:17 +08:00
|
|
|
|
}
|