public AccountFbPostViewModel(AccountFbPost accountFbPost) { Id = accountFbPost.Id; AccountId = accountFbPost.AccountId; Picture = accountFbPost.Picture; Message = accountFbPost.Message; Link = accountFbPost.Link; PostId = accountFbPost.PostId; PostTime = accountFbPost.PostTime; ShareCount = accountFbPost.ShareCount; LikeCount = accountFbPost.LikeCount; CommentCount = accountFbPost.CommentCount; Permalink = accountFbPost.Permalink; }
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); } }