2016-11-03 21:28:19 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Models
|
|
|
|
|
{
|
|
|
|
|
public class QueryDictOption : PaginationOption
|
|
|
|
|
{
|
2016-11-05 18:43:49 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典分项
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Category { get; set; }
|
2016-11-03 21:28:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典种类
|
|
|
|
|
/// </summary>
|
2016-11-03 21:53:10 +08:00
|
|
|
|
public string Define { get; set; }
|
2016-11-03 21:28:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典表查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public QueryData<Dict> RetrieveData()
|
|
|
|
|
{
|
|
|
|
|
var data = DictHelper.RetrieveDicts();
|
2016-11-05 18:43:49 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(Category))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.Category.Contains(Category));
|
|
|
|
|
}
|
2016-11-03 21:28:19 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(Name))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.Name.Contains(Name));
|
|
|
|
|
}
|
2016-11-03 21:53:10 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(Define))
|
2016-11-03 21:28:19 +08:00
|
|
|
|
{
|
2016-11-03 21:53:10 +08:00
|
|
|
|
data = data.Where(t => t.Define.ToString() == Define);
|
2016-11-03 21:28:19 +08:00
|
|
|
|
}
|
|
|
|
|
var ret = new QueryData<Dict>();
|
|
|
|
|
ret.total = data.Count();
|
|
|
|
|
// 通过option.Sort属性判断对那列进行排序,现在对字典表Category列排序
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.Category) : data.OrderByDescending(t => t.Category);
|
|
|
|
|
ret.rows = data.Skip(Offset).Take(Limit);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-29 16:46:02 +08:00
|
|
|
|
}
|