public void ClaimAFriendShip(Follow follow) { Follow found = GetFollow(follow); Follow result; StatusStateMachine <Follow> .ClaimFsRequest(found); // get the good pending depending on the existance of a follow int pending = found == null ? F_PENDINGA : F_PENDINGB; if (pending == F_PENDINGA) { Follow newFollow = NewFollowModel(follow, pending); Create(newFollow); TrySave(); result = GetFollow(newFollow); } else { found.StatusId = F_PENDINGB; Update(found); TrySave(); result = GetFollow(found); } Wrapper.Notificaton.CreateAFriendRequest(result); }
private static string GetExpliciteMessage( IHaveFriendshipStatus friendshipStatus, string finalityState = "?" ) { string startingState = StatusStateMachine <IHaveFriendshipStatus> .GetState(friendshipStatus); return($"[{startingState} -> {finalityState}]"); }
public void CreateAFriendShip(Follow follow) { Follow Reciprocal = GetFreshReciprocal(follow); Follow found = GetFollow(Reciprocal); // should be null => unexistent; StatusStateMachine <Follow> .CreateFriendship(found); Create(Reciprocal); TrySave(); }
public void RemoveAFollow(Follow friendship) { Follow found = GetFollow(friendship); StatusStateMachine <Follow> .StopFollowingAccount(found); //TODO: add custom code to handle this case Delete(found); TrySave(); }
public Follow CreateAFollow(Follow follow) { StatusStateMachine <Follow> .FollowAccount(GetFollow(follow)); Follow newFollow = NewFollowModel(follow, F_FOLLOW); Create(newFollow); TrySave(); Follow result = GetFollow(newFollow); return(result); }
public void AcceptFriend(Follow follow) { Follow found = GetFollow(follow); StatusStateMachine <Follow> .AcceptFriendShip(found); found.StatusId = F_FRIEND; Wrapper.Notificaton.CreateAcceptedFriendship(found); Update(found); TrySave(); CreateAFriendShip(follow); }
public void RemoveFriendship(Follow friendship) { foreach (Follow transiant in new Follow[] { friendship, GetFreshReciprocal(friendship) }) { Follow found = GetFollow(transiant); StatusStateMachine <Follow> .RemoveFriendship(found); Delete(found); TrySave(); } }
public void CancelFriendShipRequest(Follow friendship) { Follow found = GetFollow(friendship); StatusStateMachine <Follow> .CancelFsRequest(found); if (found.StatusId == F_PENDINGA) { DeleteFriendShipRequest(found); } else if (found.StatusId == F_PENDINGB) { UndoFriendShipRequest(found); } }
public Follow RemoveABlock(Follow blocking) { Follow found = GetFollow(blocking); StatusStateMachine <Follow> .AllowAccount(found); if (found.StatusId == F_BLOCKED) { Delete(found); return(null); } else { found.IsBlocking = false; Update(found); } TrySave(); return(GetFollow(blocking)); }
public Follow MakeABlock(Follow blocking) { Follow found = GetFollow(blocking); StatusStateMachine <Follow> .BlockAccount(found); if (found != null) { found.IsBlocking = true; Update(found); } else { Follow newFollow = new Follow() { FollowingDate = DateTime.Now, FollowedId = blocking.Followed.Id, FollowingId = blocking.Following.Id, StatusId = F_BLOCKED, ImportanceId = DEFAULT }; Reflector.Merge(newFollow, blocking); StatusStateMachine <Follow> .BlockAccount(found); newFollow.IsBlocking = true; Create(newFollow); } TrySave(); Follow result = GetFollow(blocking); return(result); }