2018-06-07 00:45:47 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Query
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class QueryUserOption : PaginationOption
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string DisplayName { get; set; }
|
2018-10-28 15:08:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-10-30 19:01:49 +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 = UserHelper.Retrieves();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(Name))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.UserName.Contains(Name));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(DisplayName))
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(t => t.DisplayName.Contains(DisplayName));
|
|
|
|
|
}
|
2018-10-30 19:01:49 +08:00
|
|
|
|
var ret = new QueryData<object>();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
ret.total = data.Count();
|
|
|
|
|
switch (Sort)
|
|
|
|
|
{
|
|
|
|
|
case "UserName":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.UserName) : data.OrderByDescending(t => t.UserName);
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayName":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.DisplayName) : data.OrderByDescending(t => t.DisplayName);
|
|
|
|
|
break;
|
|
|
|
|
case "RegisterTime":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.RegisterTime) : data.OrderByDescending(t => t.RegisterTime);
|
|
|
|
|
break;
|
|
|
|
|
case "ApprovedTime":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.ApprovedTime) : data.OrderByDescending(t => t.ApprovedTime);
|
|
|
|
|
break;
|
|
|
|
|
case "ApprovedBy":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.ApprovedBy) : data.OrderByDescending(t => t.ApprovedBy);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-10-30 19:01:49 +08:00
|
|
|
|
ret.rows = data.Skip(Offset).Take(Limit).Select(u => new
|
|
|
|
|
{
|
|
|
|
|
u.Id,
|
|
|
|
|
u.UserName,
|
|
|
|
|
u.DisplayName,
|
|
|
|
|
u.RegisterTime,
|
|
|
|
|
u.ApprovedTime,
|
|
|
|
|
u.ApprovedBy,
|
2019-03-05 13:05:19 +08:00
|
|
|
|
u.Description,
|
|
|
|
|
u.IsReset
|
2018-10-30 19:01:49 +08:00
|
|
|
|
});
|
2018-06-07 00:45:47 +08:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-24 20:53:05 +08:00
|
|
|
|
}
|