BootstrapAdmin/Bootstrap.Admin/Models/UserEntity.cs

28 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}
}