public async Task <BaseResponse <BlockList> > UnblockUserAsync(RequestBlockModel request) { var response = new BaseResponse <BlockList>(); var blockedUser = await _userService.GetUserByUsername(request.BlockedUserName); var entitiy = new BlockList { UserId = new ObjectId(request.UserId), BlockedUserId = blockedUser.Data.Id, UserName = request.UserName, BlockedUserName = request.BlockedUserName }; var isBlocked = await _blockRepository.IsBlocked(entitiy); if (isBlocked != null) { response.Data.Id = isBlocked.Id; await _blockRepository.DeleteAsync(isBlocked.Id.ToString()); response.Message = "Kullanıcı unblock yapıldı."; return(response); } response.Errors.Add("Kullanıcı blocklu değil!"); return(response); }
public async Task <BaseResponse <BlockList> > BlockUserAsync(RequestBlockModel request) { var response = new BaseResponse <BlockList>(); var blockedUser = await _userService.GetUserByUsername(request.BlockedUserName); if (blockedUser.HasError) { response.Errors.Add("Block işlemi sırasında hata oluştu!"); return(response); } var entitiy = new BlockList { UserId = new ObjectId(request.UserId), BlockedUserId = blockedUser.Data.Id, UserName = request.UserName, BlockedUserName = request.BlockedUserName }; var isBlocked = await _blockRepository.IsBlocked(entitiy); if (isBlocked == null) { var result = await _blockRepository.InsertAsync(entitiy); if (result.Id != default) { response.Data = result; return(response); } } response.Errors.Add("Kullanıcı daha önce blocklanmış!"); return(response); }
public async Task <IActionResult> UnblockUserAsync(RequestBlockModel request) { var response = await _accountService.UnblockUserAsync(request); if (response.Errors.Any()) { return(BadRequest(response.Errors)); } return(Ok(response.Message)); }