2016-10-24 20:53:05 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
|
|
|
|
using Longbow.Web.Mvc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Models
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class QueryUserOption : PaginationOption
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string DisplayName { get; set; }
|
|
|
|
|
|
|
|
|
|
public QueryData<User> RetrieveData()
|
|
|
|
|
{
|
|
|
|
|
// int limit, int offset, string name, string price, string sort, string order
|
2016-11-10 12:20:26 +08:00
|
|
|
|
var data = UserHelper.RetrieveUsers();
|
2016-10-24 20:53:05 +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));
|
|
|
|
|
}
|
|
|
|
|
var ret = new QueryData<User>();
|
|
|
|
|
ret.total = data.Count();
|
2016-11-07 21:41:17 +08:00
|
|
|
|
switch (Sort)
|
|
|
|
|
{
|
|
|
|
|
case "UserName":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.UserName) : data.OrderByDescending(t => t.UserName);
|
|
|
|
|
break;
|
|
|
|
|
case "RegisterTime":
|
|
|
|
|
data = Order == "asc" ? data.OrderBy(t => t.RegisterTime) : data.OrderByDescending(t => t.RegisterTime);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-10-24 20:53:05 +08:00
|
|
|
|
ret.rows = data.Skip(Offset).Take(Limit);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|