public async Task <AccountFbPostViewModel> GetAccountFbPost(int accountid, string postid) { var filter = new AccountFbPostSpecification(accountid, postid); var post = await _accountFbPostRepository.GetSingleBySpecAsync(filter); if (post != null) { return(new AccountFbPostViewModel(post)); } return(null); }
public async Task UpdateFbPost(int accountid, AccountFbPostViewModel model, string username) { var filter = new AccountFbPostSpecification(model.PostId); var post = await _accountFbPostRepository.GetSingleBySpecAsync(filter); if (post == null) { post = new AccountFbPost() { AccountId = accountid, CommentCount = model.CommentCount, DateCreated = DateTime.Now, DateModified = DateTime.Now, LikeCount = model.LikeCount, Link = model.Link, Message = model.Message, Picture = model.Picture, PostId = model.PostId, PostTime = model.PostTime, ShareCount = model.ShareCount, UserCreated = username, UserModified = username, Permalink = model.Permalink }; await _accountFbPostRepository.AddAsync(post); } else { post.ShareCount = model.ShareCount; post.LikeCount = model.LikeCount; post.CommentCount = model.CommentCount; post.DateModified = DateTime.Now; post.UserModified = username; await _accountFbPostRepository.UpdateAsync(post); } }