完成资源分配前端模块化处理

This commit is contained in:
yubaolee
2016-04-17 23:16:58 +08:00
parent 2f0a9a3719
commit 40ffa5f1e8
16 changed files with 285 additions and 398 deletions

View File

@@ -0,0 +1,44 @@

using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using OpenAuth.App.ViewModel;
namespace OpenAuth.App
{
public class RevelanceManagerApp
{
private readonly IRelevanceRepository _relevanceRepository;
public RevelanceManagerApp(IRelevanceRepository relevanceRepository)
{
_relevanceRepository = relevanceRepository;
}
/// <summary>
/// 添加关联
/// <para>比如给用户分配资源那么firstId就是用户IDsecIds就是资源ID列表</para>
/// </summary>
/// <param name="type">关联的类型,如"UserResource"</param>
public void Assign(string type, int firstId, int[] secIds)
{
_relevanceRepository.AddRelevance(type, secIds.ToLookup(u => firstId));
}
/// <summary>
/// 取消关联
/// </summary>
/// <param name="type">关联的类型,如"UserResource"</param>
/// <param name="firstId">The first identifier.</param>
/// <param name="secIds">The sec ids.</param>
public void UnAssign(string type, int firstId, int[] secIds)
{
_relevanceRepository.DeleteBy(type, secIds.ToLookup(u =>firstId));
}
}
}