public static Like JsonToLike(JsonObject obj) { var like = new Like() { Id = Convert.ToInt32(obj["Id"].ToString()), ParentId= Convert.ToInt32(obj["ParentId"].ToString()), UserId = Convert.ToInt32(obj["UserId"].ToString()), //Time = DateTime.ParseExact (obj ["Time"], "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture), }; DateTime? time = ActivitiesService.JsonToTime(obj["Time"]); if (time.HasValue) { like.Time = time.Value; } return like; }
public int SendLike(Like like, bool isLike) { var cms = new SendLikeOp(){ Like = like, IsLike = isLike }; var uri = string.Format("http://storage.21offserver.com/json/syncreply/SendLikeOp"); var request = (HttpWebRequest) WebRequest.Create (uri); request.Method = "PUT"; // OR POST using (var reqStream = request.GetRequestStream()) { ServiceStack.Text.JsonSerializer.SerializeToStream(cms, typeof(SendLikeOp), 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 LikeImage(Like like) { return SendLike(like, true); }
public int DislikeImage(Like like) { return SendLike(like, false); }
private void LikeAction() { try { int imageID = _Tweet.Image.Id; int likerID = AppDelegateIPhone.AIphone.GetMainUserId(); var like = new Like() { ParentId = imageID, UserId = likerID, Time = DateTime.UtcNow }; int likesCount = AppDelegateIPhone.AIphone.LikesServ.LikeImage(like); if (_Tweet != null) _Tweet.LikesCount = likesCount; InvokeOnMainThread(SetNeedsDisplay); } catch (Exception ex) { Util.LogException("LikeAction", ex); } }