public int FollowUser(Follow follow) { return SendFollow(follow, true); }
public static Follow JsonToFollow(JsonObject obj) { var follow = new Follow() { Id = Convert.ToInt32(obj["Id"].ToString()), FollowerId= Convert.ToInt32(obj["FollowerId"].ToString()), UserId = Convert.ToInt32(obj["UserId"].ToString()), //Time = DateTime.ParseExact (obj ["Time"], "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture), }; return follow; }
public void FollowUser(Follow follow) { lock (Database.Main) { var followers = GetFollowersOfUser(follow.UserId); bool alreadyFollowing = false; Follow existentRel = null; foreach (Follow follower in followers) { if (follower.FollowerId == follow.FollowerId) { alreadyFollowing = true; existentRel = follower; break; } } if (alreadyFollowing) Database.Main.Delete<Follow>(existentRel); else Database.Main.Insert(follow); } }
public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) { if (AppDelegateIPhone.AIphone.MainUser == null) return; // // In this method, we need to actually carry out the request // var section = Container.Root [indexPath.Section]; var element = section [indexPath.Row]; if (element is CommentElement) { var commentElement = (CommentElement)element; var idComment = commentElement._comment.Comment.Id; AppDelegateIPhone.AIphone.CommentServ.DeleteComment(idComment); } if (element is KeywordElement) { var kEl = (KeywordElement)element; var idKeyword = kEl.keyword.Id; AppDelegateIPhone.AIphone.KeywServ.DeleteKeyword(idKeyword); } if (element is UserElementII) { var uElem = (UserElementII)element; if (uElem.Relation != RelationType.Admirers) { var myId = AppDelegateIPhone.AIphone.MainUser.Id; var otherId = uElem.User.Id; var flw = new Follow() { FollowerId = myId, UserId = otherId, }; AppDelegateIPhone.AIphone.FlwServ.UnFollowUser(flw); } } section.Remove (element); }
void LikeUser() { if (user == null) return; int mainUserID = AppDelegateIPhone.AIphone.GetMainUserId(); if (user.Id == mainUserID) return; Action act = ()=> { try { var follow = new Follow() { UserId = user.Id, FollowerId = mainUserID, Time = DateTime.UtcNow }; if (!followingUser) AppDelegateIPhone.AIphone.FlwServ.FollowUser(follow); else AppDelegateIPhone.AIphone.FlwServ.UnFollowUser(follow); followingUser = !followingUser; UpdateFromUserId(user.Id); } catch (Exception ex) { Util.LogException("HandleFriendPicTouchUpOutside", ex); } }; if (_MembersPhotoView != null && _MembersPhotoView.View != null) { AppDelegateIPhone.ShowRealLoading(_MembersPhotoView.View, followingUser ? "Unfollowing user" : "Following user", null, act); } }
private int SendFollow(Follow follow, bool isFollow) { var cms = new SendFollowOp(){ Follow = follow, IsFollow = isFollow }; var uri = string.Format("http://storage.21offserver.com/json/syncreply/SendFollowOp"); var request = (HttpWebRequest) WebRequest.Create (uri); request.Method = "PUT"; // OR POST using (var reqStream = request.GetRequestStream()) { ServiceStack.Text.JsonSerializer.SerializeToStream(cms, typeof(SendFollowOp), reqStream); }; var response = request.GetResponse(); var stream = response.GetResponseStream(); //var responseString = new StreamReader(stream).ReadToEnd(); var jsonObj = JsonObject.Load(stream); if (jsonObj.ContainsKey("Count")) { return Convert.ToInt32(jsonObj["Count"].ToString()); } return 0; }
public int UnFollowUser(Follow follow) { return SendFollow(follow, false); }