public async Task <Location> FlagLocation() { var flagPostUrl = string.Format(Constants.LocationFlagPostUrl, Id); var httpResponse = await Core.HttpUtils.MakeRequest(flagPostUrl, null, HttpUtils.HttpMethod.Post); var responseData = await Core.HttpUtils.ProcessResponse(httpResponse); var location = AbstractModel.Deserialize <Location>(responseData); return(location); }
public async Task <Post> GetCurrentUserPost() { var currentPostUrl = string.Format(Constants.LocationGetCurrentPost, Id); var httpResponse = await Core.HttpUtils.MakeRequest(currentPostUrl, null, HttpUtils.HttpMethod.Get); var responseData = await Core.HttpUtils.ProcessResponse(httpResponse); var post = AbstractModel.Deserialize <PostResult>(responseData); return(post.Result); }
public async Task <Post> Downvote() { var upvoteUri = string.Format(Constants.PostDownvoteUrl, Id); var httpResponseMessage = await Core.HttpUtils.MakeRequest(upvoteUri, null, HttpUtils.HttpMethod.Post); var responseData = await Core.HttpUtils.ProcessResponse(httpResponseMessage); var post = AbstractModel.Deserialize <Post>(responseData); Upvotes = post.Upvotes; Downvotes = post.Downvotes; IsAnonymous = post.IsAnonymous; Rating = post.Rating; Comment = post.Comment; return(this); }
public async Task <Post> AddNewPost() { var url = Constants.PostListUrl; var method = HttpUtils.HttpMethod.Post; if (Id != -1) { url = string.Format(Constants.PostDetailUrl, Id); method = HttpUtils.HttpMethod.Put; } var jsonData = ToJson(); var httpResponse = await Core.HttpUtils.MakeRequest(url, jsonData, method); var responseData = await Core.HttpUtils.ProcessResponse(httpResponse); var newPost = AbstractModel.Deserialize <Post>(responseData); return(newPost); }