Example #1
0
        /// <summary>
        /// 编辑功能用户映射信息
        /// </summary>
        /// <param name="dto">功能用户映射信息DTO</param>
        /// <returns>业务操作结果</returns>
        public virtual async Task <OperationResult> UpdateFunctionUserMapAsync(TFunctionUserMapInputDto dto)
        {
            dto.CheckNotNull("dto");
            TFunctionUserMap map = await FunctionUserMapRepository.GetByKeyAsync(dto.Id);

            if (map == null)
            {
                return(new OperationResult(OperationResultType.QueryNull, "编号为“{0}”的功能用户映射信息不存在".FormatWith(dto.Id)));
            }
            map = dto.MapTo(map);
            if (!map.Function.Id.Equals(dto.FunctionId))
            {
                TFunction function = await FunctionRepository.GetByKeyAsync(dto.FunctionId);

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

                if (user == null)
                {
                    return(new OperationResult(OperationResultType.QueryNull, "编号为“{0}”指定编号的用户信息不存在".FormatWith(dto.UserId)));
                }
                map.User = user;
            }
            await FunctionUserMapRepository.UpdateAsync(map);

            return(new OperationResult(OperationResultType.Success, "功能用户映射信息编辑成功"));
        }
Example #2
0
        /// <summary>
        /// 删除功能用户映射信息
        /// </summary>
        /// <param name="id">功能用户映射编号</param>
        /// <returns>业务操作结果</returns>
        public virtual async Task <OperationResult> DeleteFunctionUserMapAsync(TFunctionUserMapKey id)
        {
            TFunctionUserMap map = await FunctionUserMapRepository.GetByKeyAsync(id);

            if (map == null)
            {
                return(OperationResult.NoChanged);
            }
            await FunctionUserMapRepository.DeleteAsync(map);

            return(new OperationResult(OperationResultType.Success, "功能用户映射信息删除成功"));
        }