BootstrapAdmin/Bootstrap.Admin/Models/UserEntity.cs

28 lines
1.0 KiB
C#
Raw Normal View History

2016-10-23 23:35:17 +08:00
using Bootstrap.DataAccess;
using Longbow.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Admin.Models
{
public class UserEntity
{
public int total { get; private set; }
public IEnumerable<User> rows { get; private set; }
public void RetrieveUsers(UsersPageOption option)
{
// int limit, int offset, string name, string price, string sort, string order
var data = UserHelper.RetrieveUsers(string.Empty);
if (!string.IsNullOrEmpty(option.Name))
{
data = data.Where(t => t.UserName.Contains(option.Name));
}
total = data.Count();
// TODO: 通过option.Sort属性判断对那列进行排序现在统一对名称列排序
data = option.Order == "asc" ? data.OrderBy(t => t.UserName) : data.OrderByDescending(t => t.UserName);
rows = data.Skip(option.Offset).Take(option.Limit);
}
}
}