public void SaveCommentToLocal(PostFeed newComment) { _postFeedManager.SaveNewPostToLocal(newComment); CurrentPostFeed.Comments.Add(newComment); CurrentPostFeed.NoOfComments = CurrentPostFeed.Comments.Count; RaisePropertyChanged(nameof(CurrentPostFeed)); }
public async Task <int> SaveNewPost(PostFeed newPost) { if (newPost == null) { return(0); } var result = await _postFeedService.SavePostToServer(newPost); if (result > 0) { newPost.PostFeedID = result; newPost.IsSelfPosted = true; if (newPost.PosterId == int.Parse(_keyValueCachedUtility.GetUserDefaultsKeyValue("CurrentContactId"))) { newPost.IsSelfPosted = true; } try { _postFeedRepository.UpdateItem(newPost); } catch (SQLite.SQLiteException) { } } return(result); }
private void SavePost() { if (!ProcessInternetConnection(true)) { return; } if (ProcessValidationErrors(_validator.Validate(this), true)) { IsBusy = true; NewPost = new PostFeed { ContentText = Content ?? "", ContentURL = PostImage ?? "", Poster = CurrentContact, PosterEmail = CurrentContact.EmailAdd, PosterId = CurrentContact.RemoteId, PosterFirstName = CurrentContact.FirstName, PosterLastName = CurrentContact.LastName, PosterProfilePhotoFB = CurrentContact.FBLink, PosterProfilePhoto = CurrentContact.PhotoURL, DatePosted = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToString(Constants.DateTimeFormat), DateModified = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToString(Constants.DateTimeFormat), Title = $"New Post from @{CurrentContact.AliasName}", SupportersIdsList = new System.Collections.Generic.List <int>(), NoOfSupports = 0, Comments = new System.Collections.ObjectModel.ObservableCollection <PostFeed>(), NoOfComments = 0, PostFeedLevel = 0, PostFeedParentId = 0, Id = 0 }; SendAddEditToBackground(NewPost, CurrentContact); } }
public void DeletePostFeedFromLocal(PostFeed newPost, bool getLocalFirst = false) { if (getLocalFirst) { var foundLocalComment = _postFeedManager.GetPostFeed(newPost.PostFeedID); _postFeedManager.DeletePostInLocal(foundLocalComment); return; } _postFeedManager.DeletePostInLocal(newPost); }
// GET api/posts public PostFeed Get() { var feed = new PostFeed { Title = "My Post Feed", Author = "John Doe", Summary = "A blog about Atom-Powered robots.", Posts = Posts.Select(p => new PostModel(p, GetCategoryScheme())).OrderByDescending(p => p.PublishDate).ToArray() }; return(feed); }
// GET api/posts public PostFeed Get() { var feed = new PostFeed { Title = "My Post Feed", Author = "John Doe", Summary = "A blog about Atom-Powered robots.", Posts = posts.Select(p => new PostModel(p, GetCategoryScheme())).OrderByDescending(p => p.PublishDate).ToArray() }; return feed; }
public void WriteComment() { if (!ProcessValidationErrors(_validator.Validate(this), false)) { return; } if (ProcessInternetConnection(true)) { if (DoUpdate) { Comment.ContentText = CommentText; Comment.DateModified = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToString(Constants.DateTimeFormat); RaisePropertyChanged(nameof(Comment)); } else { Comment = new PostFeed { Title = $"A new post from @{CurrentContact.FirstName} {CurrentContact.LastName}", ContentText = CommentText ?? "", ContentURL = PostImageUrl ?? "", Poster = CurrentContact, PosterEmail = CurrentContact.EmailAdd, PosterId = CurrentContact.RemoteId, PosterFirstName = CurrentContact.FirstName, PosterLastName = CurrentContact.LastName, PosterProfilePhotoFB = CurrentContact.FBLink, PosterProfilePhoto = CurrentContact.PhotoURL, DatePosted = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToString(Constants.DateTimeFormat), DateModified = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToString(Constants.DateTimeFormat), SupportersIdsList = new List <int>(), NoOfSupports = 0, PostFeedLevel = 1, PostFeedParentId = CurrentPostFeed.PostFeedID, AliasName = CurrentContact.AliasName, IsSelfPosted = true }; } IsWritePostEnabled = false; SendAddEditToBackground(Comment, CurrentContact); // Updating the UI before sending updated comment to background _eventAggregator.GetEvent <UpdateCommentListEventModel>().Publish(Comment); _keyboardHelper.HideKeyboard(); CommentText = string.Empty; } }
public async Task <HttpStatusCode> DeleteSelfPost(PostFeed PostFeed) { var result = await _postFeedService.DeleteSelfPostFromRemote(PostFeed.PostFeedID); if (result == HttpStatusCode.OK) { PostFeed.IsDelete = true; try { _postFeedRepository.UpdateItem(PostFeed); } catch (SQLite.SQLiteException) { } } return(result); }
public void AddDeductOneLikeToThisPostFromLocal(PostFeed postFeed, Contact userWhoLiked) { var postToLike = _postFeedManager.GetPostFeed(postFeed.PostFeedID); if (userWhoLiked.RemoteId == CurrentContact.RemoteId) { postToLike.IsSelfSupported = !postToLike.IsSelfSupported; } var updatePostFeed = _postFeedManager.UpdatePostFeedAndPostFeedLikeToLocal(postToLike, userWhoLiked); if (postFeed.PostFeedLevel == 1) { SelectedComment = updatePostFeed; SelectedComment.NoOfSupports = updatePostFeed.NoOfSupports; } else { CurrentPostFeed = updatePostFeed; } }
public PostFeed UpdatePostFeedAndPostFeedLikeToLocal(Entity.PostFeed existingPostFeed, Entity.Contact userWhoLiked) { try { if (existingPostFeed.PosterId == int.Parse(_keyValueCachedUtility.GetUserDefaultsKeyValue("CurrentContactId"))) { existingPostFeed.IsSelfPosted = true; } var postFeedLikeInLocal = _postFeedRepository.GetPostFeedLikeByContactId(userWhoLiked.RemoteId, existingPostFeed.PostFeedID); existingPostFeed.NoOfSupports = (postFeedLikeInLocal == null) ? existingPostFeed.NoOfSupports + 1 : existingPostFeed.NoOfSupports - 1; if (postFeedLikeInLocal == null) { _postFeedRepository.UpdateItem(new PostFeedLike { ContactID = userWhoLiked.RemoteId, PostFeedID = existingPostFeed.PostFeedID }); } else { _postFeedRepository.DeleteTable(postFeedLikeInLocal); } _postFeedRepository.UpdateItem(existingPostFeed); _updatedPostFeedFromLocal = _postFeedRepository.GetPostFeedById(existingPostFeed.PostFeedID); // 01-11-2018 12:31pm REYNZ // since comments are not saved locally because sqlite cannot saved List, i explicitly added it before returning the updated post to the caller //existingPostFeed.Comments = postComments; _updatedPostFeedFromLocal.Comments = existingPostFeed.Comments; _updatedPostFeedFromLocal.NoOfSupports = existingPostFeed.NoOfSupports; return(_updatedPostFeedFromLocal); } catch (SQLite.SQLiteException) { return(_updatedPostFeedFromLocal); } }
public void SaveNewPostToLocal(PostFeed newPost) { try { var localPost = _postFeedRepository.GetPostFeedById(newPost.PostFeedID); if (localPost == null) { localPost = newPost; } else { var localId = localPost.Id; localPost = newPost; localPost.Id = localId; } if (localPost.PosterId == int.Parse(_keyValueCachedUtility.GetUserDefaultsKeyValue("CurrentContactId"))) { localPost.IsSelfPosted = true; } if (newPost.Poster != null) { localPost.Poster = newPost.Poster; localPost.PosterFirstName = newPost.Poster.FirstName; localPost.PosterLastName = newPost.Poster.LastName; _contactRepository.UpdateItem(localPost.Poster); } _postFeedRepository.UpdateItem(localPost); } catch (SQLite.SQLiteException) { } }
private void EditPost() { if (!ProcessInternetConnection(true)) { return; } if (ProcessValidationErrors(_validator.Validate(this), true)) { IsBusy = true; NewPost = new PostFeed { Id = OldPost.Id, PostFeedID = OldPost.PostFeedID, ContentText = Content, ContentURL = PostImage ?? (OldPost.ContentURL ?? ""), Poster = CurrentContact, PosterEmail = CurrentContact.EmailAdd, PosterId = CurrentContact.RemoteId, PosterFirstName = CurrentContact.FirstName, PosterLastName = CurrentContact.LastName, PosterProfilePhotoFB = CurrentContact.FBLink, PosterProfilePhoto = CurrentContact.PhotoURL, DatePosted = OldPost.DatePosted, DateModified = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToString(Constants.DateTimeFormat), Title = $"New Post from @{CurrentContact.AliasName}", SupportersIdsList = OldPost.SupportersIdsList, NoOfSupports = OldPost.NoOfSupports, Comments = OldPost.Comments, NoOfComments = OldPost.NoOfComments, PostFeedLevel = 0, PostFeedParentId = 0 }; SendAddEditToBackground(NewPost, CurrentContact); } }
public void DeletePostFeedAndItsComments(PostFeed postFeed) { }
public void DeletePostInLocal(PostFeed PostFeed) => _postFeedRepository.DeletePostFeedAndItsComments(PostFeed);
public Task <int> SavePostToServer(PostFeed newPost) => Task.FromResult(0);
public Entity.PostFeed ReadPostFeedFromLocal(PostFeed newPost) => _postFeedManager.GetPostFeed(newPost.PostFeedID);