添加角色处理

This commit is contained in:
yubaolee
2015-11-19 21:49:39 +08:00
parent 6906e969ac
commit 119948ccb7
24 changed files with 1763 additions and 899 deletions

View File

@@ -0,0 +1,41 @@
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)
{
return Context.Roles.OrderBy(u => u.Name).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
public int GetRoleCntInOrgs(params int[] orgIds)
{
return LoadInOrgs(orgIds).Count();
}
public IEnumerable<Role> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
{
return LoadInOrgs(orgIds).OrderBy(u => u.Name).Skip((pageindex - 1) * pagesize).Take(pagesize);
}
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;
}
}
}