public StatusViewModel GetStatusViewModelByStatusId(string statusId) { Status status = this.GetStatusByStatusId(statusId); IStatusLocationRepository sttLocation = new StatusLocationRepository(this._db); IStatusMessageRepository sttMessageRepository = new StatusMessageRepository(this._db); IStatusImageRepository sttImageRepository = new StatusImageRepository(this._db); IUserRepository userRepository = new UserRepository(this._db); ILikeRepository likeRepository = new LikeRepository(this._db); IShareRepository shareRepository = new ShareRepository(this._db); ICommentRepository commentRepository = new CommentRepository(this._db); var message = sttMessageRepository.GetMessageByStatusId(statusId); var messageProcessed = ProcessComment.ProcessMessage(message); LinkPreview linkPreview = ProcessMessage.GetFirstLinkPreview(message); var userOwner = userRepository.GetUserById(status.UserId); var statusViewModel = new StatusViewModel { StatusId = statusId, TimePost = status.TimePost, Location = sttLocation.GetLocationForStatus(statusId), Message = messageProcessed, Images = sttImageRepository.GetListImage(statusId), UserOwner = userOwner, LinkPreview = linkPreview, NumShared = shareRepository.GetNumShare(statusId), ListUserLiked = likeRepository.GetListUserLiked(statusId) }; return(statusViewModel); }
public static string GetHtml_statusBoxLikeShare(string statusId, string userId) { ApplicationDbContext dbContext = new ApplicationDbContext(); ILikeRepository likeRepository = new LikeRepository(dbContext); int isLike = likeRepository.IsLiked(statusId, userId); string strLike = (isLike == 1) ? "unlike" : "like"; return "<div class='box-like-share'>" + "<a class='like' data-isliked='" + isLike + "' data-statusid='" + statusId + "'>" + strLike + "</a> <span data-statusid='" + statusId + "' class='glyphicon glyphicon-thumbs-up icon-liked' data-toggle='modal' data-target='#liked'></span> <span id='numLike-" + statusId + "'>" + likeRepository.Count(statusId) + "</span>" + " . " + "<a class='share' data-statusid='" + statusId + "'>Share</a> <span class='glyphicon glyphicon-share-alt'></span> <span id='numShare-" + statusId + "'>0</span>" + "</div>"; }
public JsonResult GetPeopleLiked(string statusId) { ILikeRepository likeRepository = new LikeRepository(_dbContext); var listUserLiked = likeRepository.GetListUserLiked(statusId); return Json(listUserLiked, JsonRequestBehavior.AllowGet); }