Ejemplo n.º 1
0
        /// <summary>
        /// 增加功能用户映射信息
        /// </summary>
        /// <param name="dto">功能用户映射信息DTO</param>
        /// <returns>业务操作结果</returns>
        public virtual async Task <OperationResult> CreateFunctionUserMapAsync(TFunctionUserMapInputDto dto)
        {
            dto.CheckNotNull("dto");
            if (await FunctionUserMapRepository.CheckExistsAsync(m => m.Function.Id.Equals(dto.FunctionId) && m.User.Id.Equals(dto.UserId)))
            {
                return(OperationResult.Success);
            }
            TFunction function = await FunctionRepository.GetByKeyAsync(dto.FunctionId);

            if (function == null)
            {
                return(new OperationResult(OperationResultType.QueryNull, "编号为“{0}”的功能信息不存在".FormatWith(dto.FunctionId)));
            }
            TUser user = await UserRepository.GetByKeyAsync(dto.UserId);

            if (user == null)
            {
                return(new OperationResult(OperationResultType.QueryNull, "编号为“{0}”的用户信息不存在".FormatWith(dto.UserId)));
            }
            TFunctionUserMap map = dto.MapTo <TFunctionUserMap>();

            map.Function = function;
            map.User     = user;
            await FunctionUserMapRepository.InsertAsync(map);

            return(new OperationResult(OperationResultType.Success, "功能用户映射信息添加成功"));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 检查用户功能映射信息信息是否存在
 /// </summary>
 /// <param name="predicate">检查谓语表达式</param>
 /// <param name="id">更新的用户功能映射信息编号</param>
 /// <returns>用户功能映射信息是否存在</returns>
 public Task <bool> CheckFunctionUserMapExists(Expression <Func <FunctionUserMap, bool> > predicate, int id = 0)
 {
     return(FunctionUserMapRepository.CheckExistsAsync(predicate, id));
 }