Beispiel #1
0
        /// <summary>
        /// 申请友情链接
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task FriendshipLinkApply(FriendshipLinkCreateOrUpdate input)
        {
            var _default = await _cacheManager.GetCache(BlogCacheNames.CacheFriendshipLinkApply)
                           .GetOrDefaultAsync($"{_clientInfoProvider.ClientIpAddress}");

            if (_default != null)
            {
                throw new UserFriendlyException(401, "请等待十分钟后再申请");
            }
            input.Id = null;
            FriendshipLink link = ObjectMapper.Map <FriendshipLink>(input);

            link.Ip    = _clientInfoProvider.ClientIpAddress;
            link.Order = 999;
            await _blogFriendshipLinkRepository.InsertAsync(link);

            await _cacheManager.GetCache(BlogCacheNames.CacheFriendshipLinkApply)
            .SetAsync(_clientInfoProvider.ClientIpAddress, DateTime.Now.ToString());
        }
Beispiel #2
0
        public async Task FriendshipLinkCreateOrUpdate(FriendshipLinkCreateOrUpdate input)
        {
            FriendshipLink link = null;

            if (input.Id.HasValue)
            {
                var _link = await _blogFriendshipLinkRepository.FirstOrDefaultAsync(input.Id.Value);

                if (_link == null)
                {
                    throw new UserFriendlyException(404, "该友情链接不存在");
                }
                link = ObjectMapper.Map(input, _link);
            }
            else
            {
                link = ObjectMapper.Map <FriendshipLink>(input);
                //此接口为管理员接口,添加默认审核通过,修改不更改审核状态
                link.ToExamine = ToExamine.Adopt;
                link.Ip        = _clientInfoProvider.ClientIpAddress;
            }
            await _blogFriendshipLinkRepository.InsertOrUpdateAsync(link);
        }