OpenAuth.Net/OpenAuth.Repository/RoleRepository.cs

42 lines
1.2 KiB
C#
Raw Normal View History

2015-11-19 21:49:39 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository
{
public class RoleRepository :BaseRepository<Role>, IRoleRepository
{
public IEnumerable<Role> LoadRoles(int pageindex, int pagesize)
{
2015-11-19 22:47:56 +08:00
return Context.Roles.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
2015-11-19 21:49:39 +08:00
}
public int GetRoleCntInOrgs(params int[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
{
2015-11-19 22:47:56 +08:00
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
2015-11-19 21:49:39 +08:00
}
public void Delete(int id)
{
Delete(u =>u.Id == id);
}
public IEnumerable<Role> LoadInOrgs(params int[] orgId)
{
var result = from role in Context.Roles.Where(u => orgId.Contains(u.OrgId)) select role;
return result;
}
}
}