/// <summary> /// Retrieves a user object from a token /// </summary> /// <param name="userToken"></param> /// <returns></returns> public User GetUserFromToken(string userToken) { busUser User = new busUser(); User userEntity = (from user in User.Context.Users join tk in User.Context.UserTokens on user.Id equals tk.UserId where tk.Token == userToken && tk.Expires.CompareTo(DateTime.Now) > -1 select user).FirstOrDefault(); return(userEntity); }
public bool AddComment(string commentText, string userId) { using (busComment busComment = CodePasteFactory.GetComment()) { Comment comment = busComment.NewEntity(); comment.CommentText = commentText; comment.SnippetId = Entity.Id; comment.UserId = userId; busUser user = CodePasteFactory.GetUser(); comment.Author = user.GetNameFromUserId(userId); if (comment.Author == null) { SetError("Couldn't add comment. Invalid User id."); return(false); } if (!busComment.Save()) { SetError(busComment.ErrorMessage); return(false); } } return(true); }