public async Task <IActionResult> Add([FromBody] BZFollowDto dto)
        {
            var follow = _mapper.Map <BZFollowModel>(dto);
            var result = await _followRepository.InsertAsync(follow);

            var data = result?.Entity == null ? false : true;

            if (data)
            {
                _cacheService.Remove(nameof(BZFollowModel));
            }
            return(Ok(data));
        }
 public async Task <IActionResult> ToggleFollow([FromBody] BZFollowDto Dto)
 {
     if (string.IsNullOrWhiteSpace(Dto.Id))
     {
         return(await Add(Dto));
     }
     else
     {
         if (await _bZFollowRepository.ChangeStateByIdAsync(Dto.Id, Dto.Status == 0 ? -1 : 0, ""))
         {
             _cacheService.Remove(nameof(BZFollowModel));
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 ///  切换是否收藏
 /// </summary>
 /// <returns></returns>
 public async Task <BaseResponse> ToggleFollow(BZFollowDto dto)
 {
     return(await HttpRequestWithValidate($"api/client/Follow/Toggle", HttpMethod.Patch, dto.BuildHttpContent()));
 }