Beispiel #1
0
 public bool IsEnrolled(ApplicationUser user)
 {
     if (UserPurchases.Select(up => up.ApplicationUserId).Any(id => id == user.Id))
     {
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        /// <summary>
        /// if a user purchase this course, then enroll this user to the course
        /// </summary>
        public void Enroll(ApplicationUser user, Order order)
        {
            // add user purchase record
            var purchasedCourse = ApplicationUserCourse.Create(user, order);

            UserPurchases.Add(purchasedCourse);
            // increse enrollment
            EnrollmentCount += 1;
        }
        protected void DisplayCreateReview(User currentUser, string ISBN)
        {
            this.currentUserOwnsBook       = UserPurchases.hasUserPurchasedBook(currentUser.userID, ISBN, ConfigurationManager.ConnectionStrings["GeekTextConnection"].ConnectionString);
            this.hasAlreadyCommented       = BookReview.existsUserComment(currentUser.userID, ISBN, ConfigurationManager.ConnectionStrings["GeekTextConnection"].ConnectionString);
            createReview_Name.Text         = currentUser.userFirstName;
            radioFullname.InnerText        = currentUser.userFirstName + " " + currentUser.userLastName;
            radioNickname.InnerText        = currentUser.userNickName;
            reviewWelcomeMessage.InnerText = hasAlreadyCommented ? "Edit your review" : "Add a review for this book";
            textAreaTitle.InnerText        = hasAlreadyCommented ? "Modify your review" : "Write a review of the book";

            if (hasAlreadyCommented)
            {
                BookReview lastReview = BookReview.getBookReviewsByUserAndISBN(currentUser.userID, ISBN, ConfigurationManager.ConnectionStrings["GeekTextConnection"].ConnectionString);
                prefillReviewDisplay(lastReview);
            }
        }