public async Task <FollowModel[]> Handle(FollowingQuery request, CancellationToken cancellationToken) { FollowModel[] result = null; _logger.Debug("Reading following list for user {Nickname} with parameters {@Request}", request.Nickname, request); using (var tx = _session.BeginTransaction()) { FollowModel model = null; User followed = null; User follower = null; var followersQuery = _session.QueryOver <Follow>() .Inner.JoinAlias(f => f.Followed, () => followed) .Inner.JoinAlias(f => f.Follower, () => follower) .Where(Restrictions.Eq(Projections.Property(() => follower.Nickname), request.Nickname)) .SelectList(fields => fields .Select(f => followed.Nickname).WithAlias(() => model.Nickname) .Select(f => followed.ProfilePicture.RawBytes).WithAlias(() => model.ProfilePicture) ) .TransformUsing(Transformers.AliasToBean <FollowModel>()); result = (await followersQuery.ListAsync <FollowModel>(cancellationToken)).ToArray(); } return(result); }
public async Task Delete(FollowModel model) { var modelToUpdate = await _context.Follows.FirstOrDefaultAsync(s => s.Id == model.Id); _context.Remove(modelToUpdate); await _context.SaveChangesAsync(); }
public override async Task <OperationResult <VoidResponse> > Follow(FollowModel model, CancellationToken ct) { return(await Task.Run(() => { if (!TryReconnectChain(ct)) { return new OperationResult <VoidResponse>(new AppError(LocalizationKeys.EnableConnectToBlockchain)); } var keys = ToKeyArr(model.PostingKey); if (keys == null) { return new OperationResult <VoidResponse>(new AppError(LocalizationKeys.WrongPrivatePostingKey)); } var op = model.Type == FollowType.Follow ? new FollowOperation(model.Login, model.Username, DitchFollowType.Blog, model.Login) : new UnfollowOperation(model.Login, model.Username, model.Login); var resp = _operationManager.BroadcastOperationsSynchronous(keys, ct, op); var result = new OperationResult <VoidResponse>(); if (!resp.IsError) { result.Result = new VoidResponse(); } else { OnError(resp, result); } return result; }, ct)); }
public List <InformationModel> GetInformation(string condition, Guid adminId) { // InformationModel List 最终提交到页面的数据集 // InformationModel 继承至 Information // 目的是为了包含FollowModel List List <InformationModel> InformationModelList = new List <InformationModel>(); List <Information> InformationList = new List <Information>(); if (string.IsNullOrEmpty(condition)) { // 如果condition没有值 // 首先获取前50条数据记录到 InformationList InformationList = _informationBLL.GetInformationByAnythingswithGroupLeader(50, adminId).ToList(); } else { // 如果condition有值 就按条件查询 InformationList = _informationBLL.GetInformationByAnythingswithGroupLeader(condition, adminId).ToList(); } List <Information> InfoList = new List <Information>(); InfoList = InformationList.ToList(); // 然后循环InformationList // 构造 InformationModelList foreach (Information item in InformationList) { InformationModel info = new InformationModel(item); List <FollowModel> followModelList = new List <FollowModel>(); List <FollowRecord> followRecordList = new List <FollowRecord>(); followRecordList = _followRecordBLL.GetFollowRecordByInformationId(info.Id).ToList(); foreach (FollowRecord fr in followRecordList) { FollowModel fm = new FollowModel(); fm.FollowName = _followBLL.GetFollow(fr.FollowId).FollowItem; fm.FollowValue = fr.FollowValue; followModelList.Add(fm); } info.FollowList = followModelList.AsEnumerable(); // 获取收集员的账号 var m = _memberBLL.GetMemberById(info.MemberId); if (m != null) { info.MemberAccount = m.Account; InformationModelList.Add(info); } } return(InformationModelList); }
public async Task <IActionResult> PutFollowModel([FromRoute] int id, [FromBody] FollowModel followModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != followModel.ID) { return(BadRequest()); } _context.Entry(followModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FollowModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override async Task <OperationResult <VoidResponse> > Follow(FollowModel model, CancellationToken ct) { var isConnected = await TryReconnectChain(ct); if (!isConnected) { return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.EnableConnectToBlockchain))); } var keys = ToKeyArr(model.PostingKey); if (keys == null) { return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.WrongPrivatePostingKey))); } var op = model.Type == Models.Enums.FollowType.Follow ? new FollowOperation(model.Login, model.Username, Ditch.Golos.Models.FollowType.Blog, model.Login) : new UnfollowOperation(model.Login, model.Username, model.Login); var resp = await _operationManager.BroadcastOperationsSynchronous(keys, ct, op); var result = new OperationResult <VoidResponse>(); if (resp.IsError) { result.Exception = new RequestException(resp); } else { result.Result = new VoidResponse(); } return(result); }
public ActionResult Follow(FollowModel model) { var userId = UserContextProvider.Get().Id; UserService.CreateSubscription(userId, model.UserToFollowId); UnitOfWork.Commit(); return(Ok()); }
public FollowModel ConvertToViewModel_follow(tbfollowing model) { var vm = new FollowModel(); vm.id = model.id; vm.flag_follow = model.flag_follow; vm.userid = model.userid; return(vm); }
public bool InsertFollow(string token, string emailOrUsername) { FollowModel newFollow = new FollowModel(); newFollow.Sender = new MongoDBRef("account", FindAccountByToken(token)._id); // start by getting the reference to our follow if (!Utility.IsEmail(emailOrUsername)) { // if it is username/discriminator string[] data = emailOrUsername.Split('#'); if (data[1] != null) { AccountModel follow = FindAccountByUsernameAndDiscriminator(data[0], data[1]); if (follow != null) { newFollow.Target = new MongoDBRef("account", follow._id); } else { return(false); } } } else { // if it is email AccountModel follow = FindAccountByEmail(emailOrUsername); if (follow != null) { newFollow.Target = new MongoDBRef("account", follow._id); } else { return(false); } } if (newFollow.Target != newFollow.Sender) { // Does the friendship already exists ? var query = Query.And( Query <FollowModel> .EQ(u => u.Sender, newFollow.Sender), Query <FollowModel> .EQ(u => u.Target, newFollow.Target)); // if there is no friendship, create one! if (follows.FindOne(query) == null) { follows.Insert(newFollow); } return(true); } return(false); }
public bool Unfollow(FollowModel followModel) { FollowDTO followdto = new FollowDTO(); followdto.UserID = Guid.Parse(followModel.UserID); followdto.UserToFollowID = Guid.Parse(followModel.UserToFollowID); UserBusinessContext.UnFollow(followdto); return(true); }
public ActionResult DeleteFollower(FollowModel follower) { _followService.RemoveFollower(new FollowBLL() { Id = follower.Id, }); return(View()); }
private void FollowTest(StringBuilder sb, int num) { sb.Append($"{num}) FollowTest : "); StepFinished?.Invoke(sb.ToString()); // Load last created post var getPosts = new PostsModel(PostType.New) { Login = _user.Login }; var postsResp = _api.GetPosts(getPosts, CancellationToken.None) .Result; if (!postsResp.IsSuccess) { sb.AppendLine($"fail. Reason:{Environment.NewLine} {postsResp.Error.Message}"); return; } if (postsResp.Result.Results.Count == 0) { sb.AppendLine("fail. Reason:{Environment.NewLine} There are no Posts to Follow!"); return; } var testPost = postsResp.Result.Results.First(); var votereq = new FollowModel(_user, FollowType.Follow, testPost.Author); var rez = _api.Follow(votereq, CancellationToken.None) .Result; if (!rez.IsSuccess) { sb.AppendLine($"fail. Reason:{Environment.NewLine} {rez.Error.Message}"); return; } Task.Delay(10000); var userFriendsReq = new UserFriendsModel(_user.Login, FriendsType.Followers) { Login = _user.Login, Offset = testPost.Author, Limit = 1 }; var verifyResp = _api.GetUserFriends(userFriendsReq, CancellationToken.None).Result; if (!verifyResp.IsSuccess) { sb.AppendLine($"fail. Reason:{Environment.NewLine} {verifyResp.Error.Message}"); return; } if (verifyResp.Result.Results.Count != 1) { sb.AppendLine($"fail. Reason:{Environment.NewLine} user ({testPost.Author}) not found!"); return; } sb.AppendLine("pass."); }
public bool Post(FollowModel followModel) { FollowDTO followdto = new FollowDTO(); followdto.UserID = Guid.Parse(followModel.UserID); followdto.UserToFollowID = Guid.Parse(followModel.UserToFollowID); bool result = UserBusinessContext.Follow(followdto); return(result); }
public void FollowModel_Empty_Username() { var user = Users.First().Value; var request = new FollowModel(user, FollowType.Follow, string.Empty); var result = Validate(request); Assert.IsTrue(result.Count == 1); Assert.IsTrue(result[0].ErrorMessage == Localization.Errors.EmptyUsernameField); }
public async Task <IActionResult> GetFollow([FromQuery] FollowModel followModel) { try { return(Ok(await _profileService.GetFollow(followModel.id, followModel.idToFollow))); } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task <IActionResult> PostFollowModel([FromBody] FollowModel followModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Follow.Add(followModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFollowModel", new { id = followModel.ID }, followModel)); }
private async Task <ErrorBase> Follow(UserFriend item, CancellationToken ct) { var request = new FollowModel(User.UserInfo, item.HasFollowed ? Models.Enums.FollowType.UnFollow : Models.Enums.FollowType.Follow, item.Author); var response = await Api.Follow(request, ct); if (response.IsSuccess) { item.HasFollowed = !item.HasFollowed; } return(response.Error); }
public HttpResponseMessage Follow(string FOLLOWED_UserName, string FOLLOWING_UserName, int conferenceId) { if (FOLLOWED_UserName == FOLLOWING_UserName) { return(ResponseFail(StringResource.You_can_not_follow_yourself)); } else { var account_followed = db.ACCOUNTs.SingleOrDefault(x => x.UserName == FOLLOWED_UserName); var account_following = db.ACCOUNTs.SingleOrDefault(x => x.UserName == FOLLOWING_UserName); var conference = db.CONFERENCEs.SingleOrDefault(x => x.CONFERENCE_ID == conferenceId); var isFollow = new FollowModel().CheckFollow(FOLLOWED_UserName, FOLLOWING_UserName, conferenceId); if (account_followed == null || account_following == null) { return(ResponseFail(StringResource.Account_does_not_exist)); } else if (conference == null) { return(ResponseFail(StringResource.Conference_do_not_exist)); } else if (isFollow) { return(ResponseSuccess(StringResource.Follow_is_exist)); } else { var follower = new FOLLOWER_RELATIONSHIP(); follower.FOLLOWED_UserName = FOLLOWED_UserName; follower.FOLLOWED_CURRENT_LAST_NAME = account_followed.CURRENT_LAST_NAME; follower.FOLLOWED_CURRENT_FIRST_NAME = account_followed.CURRENT_FIRST_NAME; follower.FOLLOWED_CURRENT_MIDDLE_NAME = account_followed.CURRENT_MIDDLE_NAME; follower.FOLLOWING_UserName = FOLLOWING_UserName; follower.FOLLOWING_CURRENT_LAST_NAME = account_following.CURRENT_LAST_NAME; follower.FOLLOWING_CURRENT_FIRST_NAME = account_following.CURRENT_FIRST_NAME; follower.FOLLOWING_CURRENT_MIDDLE_NAME = account_following.CURRENT_MIDDLE_NAME; follower.FROM_DATE = DateTime.Now; follower.CONFERENCE_ID = conferenceId; follower.CONFERENCE_NAME = conference.CONFERENCE_NAME; follower.CONFERENCE_NAME_EN = conference.CONFERENCE_NAME_EN; try { db.FOLLOWER_RELATIONSHIP.Add(follower); db.SaveChanges(); return(ResponseSuccess(StringResource.Success)); } catch { return(ResponseFail(StringResource.Can_not_follow)); } } } }
private async Task <ErrorBase> Follow(UserProfileResponse userProfileResponse, CancellationToken ct) { var request = new FollowModel(User.UserInfo, userProfileResponse.HasFollowed ? FollowType.UnFollow : FollowType.Follow, UserName); var response = await Api.Follow(request, ct); if (response.IsSuccess) { userProfileResponse.HasFollowed = !userProfileResponse.HasFollowed; } return(response.Error); }
public List <InformationModel> GetInformation(string condition) { // InformationModel List 最终提交到页面的数据集 // InformationModel 继承至 Information // 目的是为了包含FollowModel List List <InformationModel> InformationModelList = new List <InformationModel>(); List <Information> InformationList = new List <Information>(); if (string.IsNullOrEmpty(condition)) { // 如果condition没有值 // 首先获取前50条数据记录到 InformationList InformationList = _informationBLL.GetinformationLimitedwithSpecificMember(50, System.Web.HttpContext.Current.Session["member"].ToString()).ToList(); } else { // 如果condition有值 就按条件查询 InformationList = _informationBLL.GetInformationByAnythingswithSpecificMember(condition, System.Web.HttpContext.Current.Session["member"].ToString()).ToList(); } List <Information> InfoList = new List <Information>(); InfoList = InformationList.ToList(); // 然后循环InformationList // 构造 InformationModelList foreach (Information item in InformationList) { InformationModel info = new InformationModel(item); List <FollowModel> followModelList = new List <FollowModel>(); List <FollowRecord> followRecordList = new List <FollowRecord>(); followRecordList = _followRecordBLL.GetFollowRecordByInformationId(info.Id).ToList(); foreach (FollowRecord fr in followRecordList) { FollowModel fm = new FollowModel(); fm.FollowName = _followBLL.GetFollow(fr.FollowId).FollowItem; fm.FollowValue = fr.FollowValue; followModelList.Add(fm); } info.FollowList = followModelList.AsEnumerable(); // 获取收集员的账号 info.MemberAccount = _memberBLL.GetMemberById(info.MemberId).Account; InformationModelList.Add(info); } return(InformationModelList); }
public async Task <IActionResult> UnFollow([FromQuery] FollowModel followModel, [FromHeader(Name = "Authorization")] string jwt) { try { await _profileService.UnFollow(followModel.id, followModel.idToFollow, jwt); return(Ok()); } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } }
public bool Post(FollowModel followModel) { //fetch user to follow's userid from url and fetch loggedin user id from session // string ass = HttpContext.Current.Session["UserID"].ToString(); FollowDTO followdto = new FollowDTO(); followdto.UserID = Guid.Parse(followModel.UserID); followdto.UserToFollowID = Guid.Parse(followModel.UserToFollowID); bool result = UserBusinessContext.Follow(followdto); return(result); }
private async Task <Exception> Follow(UserProfileResponse userProfileResponse, CancellationToken ct) { var hasFollowed = userProfileResponse.HasFollowed; var request = new FollowModel(AppSettings.User.UserInfo, hasFollowed ? FollowType.UnFollow : FollowType.Follow, UserName); var response = await Api.Follow(request, ct); if (response.IsSuccess) { userProfileResponse.HasFollowed = !hasFollowed; } return(response.Exception); }
public async Task <OperationResult <VoidResponse> > Follow(FollowModel model, CancellationToken ct) { var results = Validate(model); if (results.Any()) { return(new OperationResult <VoidResponse>(new ValidationError(results))); } var result = await _ditchClient.Follow(model, ct); Trace($"user/{model.Username}/{model.Type.ToString().ToLowerInvariant()}", model.Login, result.Error, model.Username, ct);//.Wait(5000); return(result); }
private List <FollowModel> TakeSameTask(TextBox resultTextBox) { // Init current person model list FollowModel currentPersonFollowList = new FollowModel(); List <FollowModel> findResultList = new List <FollowModel>(); var followList = FollowsList.Follows; SetMessage("Start search method...", false, resultTextBox); for (int firstPerson = 0; firstPerson < followList.Count; firstPerson++) { // Get data from List to current model currentPersonFollowList = followList[firstPerson]; SetMessage($"Current person: {currentPersonFollowList.PageOwnerName}", true, resultTextBox); for (int secondPerson = 0; secondPerson < followList.Count; secondPerson++) { if (secondPerson == firstPerson) { continue; } // Get next person data and contain var secondPersonFollowList = followList[secondPerson]; SetMessage($"Person for check: {secondPersonFollowList.PageOwnerName}", true, resultTextBox); // First person list cycle for (int firstPersonListIterator = 0; firstPersonListIterator < currentPersonFollowList.FollowsData.Count; firstPersonListIterator++) { // Second person list cycle for (int secondPersonListIterator = 0; secondPersonListIterator < secondPersonFollowList.FollowsData.Count; secondPersonListIterator++) { // Check if data same, increment count if (currentPersonFollowList.FollowsData[firstPersonListIterator].FollowPageAddress == secondPersonFollowList.FollowsData[secondPersonListIterator].FollowPageAddress) { followList[firstPerson].FollowsData[firstPersonListIterator].SameFollowCount += 1; followList[firstPerson].FollowsData[firstPersonListIterator].SameFollowPeople.Add(secondPersonFollowList.PageOwnerName); followList[secondPerson].FollowsData.Remove(followList[secondPerson].FollowsData[secondPersonListIterator]); secondPersonListIterator--; } } } } } return(followList); }
public static FollowEntity ToEntity(this FollowModel FM) { if (FM != null) { FollowEntity FE = new FollowEntity(); FE.FollowedId = FM.Followed.Id; FE.FollowerId = FM.Follower.Id; return(FE); } else { return(null); } }
public static FollowModel ToModel(this FollowEntity FE) { if (FE != null) { UserRepository repoU = new UserRepository(); FollowModel FM = new FollowModel(); FM.Followed = repoU.GetOne(FE.FollowedId).MapTo <UserModel>(); FM.Follower = repoU.GetOne(FE.FollowerId).MapTo <UserModel>(); return(FM); } else { return(null); } }
public async Task Follow(Guid UserId) { var currentUser = _currentUserProvider.GetUserId; var model = new FollowModel(new FollowEntity { UserId = _currentUserProvider.GetUserId, FollowUserId = UserId, Id = Guid.NewGuid() } ); await _followRepository.Add(model); await this._currentUserProvider.ReloadFollowing(); }
public async Task <OperationResult <VoidResponse> > Follow(FollowModel model, CancellationToken ct) { var results = Validate(model); if (results != null) { return(new OperationResult <VoidResponse>(results)); } var result = await _ditchClient.Follow(model, ct); await Trace($"user/{model.Username}/{model.Type.ToString().ToLowerInvariant()}", model.Login, result.Exception, model.Username, ct); return(result); }
private async Task <ErrorBase> Follow(UserFriend item, CancellationToken ct) { var hasFollowed = item.HasFollowed; var request = new FollowModel(AppSettings.User.UserInfo, item.HasFollowed ? Models.Enums.FollowType.UnFollow : Models.Enums.FollowType.Follow, item.Author); var response = await Api.Follow(request, ct); if (response.IsSuccess) { item.HasFollowed = !hasFollowed; } CashPresenterManager.Update(item); return(response.Error); }