public CommentInfo(CommentInfo model) { this.UserId = model.UserId; this.UserName = model.UserName; this.CreationDate = model.CreationDate; this.CommentId = model.CommentId; this.CommentText = model.CommentText; this.CommentVote = model.CommentVote; this.isAvatarExists = model.isAvatarExists; }
public PartialViewResult _GetCommentData(CommentInfo model) { if (model.UserId != WebSecurity.CurrentUserId) { using (var context = new SimpleMembershipContext()) { var record = context.Likes.FirstOrDefault(l => l.UserId == WebSecurity.CurrentUserId && l.CommentId == model.CommentId); if (record == null) { context.Likes.Add(new Like { CommentId = model.CommentId, UserId = WebSecurity.CurrentUserId, Vote = 1 }); model.CommentVote++; } else { if (record.Vote == 0) { record.Vote++; model.CommentVote++; } else { model.CommentVote--; record.Vote--; } } context.SaveChanges(); } } return PartialView("_GetCommentData", model); }