public int CastVote(int commentID, int userID, muscle_log.framework.Util.Enum.Votes value) { var previousVotes = _repo.GetAll(v => v.CommentID == commentID && v.UserID == userID); if (previousVotes.Count() > 1) { throw new ApplicationException("The user with the ID " + userID + " casted multiple votes to the comment with the ID " + commentID); } var vote = previousVotes.FirstOrDefault(); if (vote != null) { vote.Value = (int)value; _repo.Update(vote); } else { vote = new ml_CommentVotes(); vote.CRDT = vote.LUDT = DateTime.Now; vote.UserID = userID; vote.CommentID = commentID; vote.Value = (int)value; _repo.Insert(vote); } return GetCommentVotesValue(commentID); }
public IEnumerable<ml_ForumThread> ListThreads(muscle_log.framework.Util.Enum.Forums forum) { return _repo.GetAll(thread => thread.Forum == forum.ToString()); }