Пример #1
0
        public bool coomentBook(AudioBook ab, string Text)
        {
            bool reviewed = false;

            foreach (MongoDBRef refId in this.ReviewdAB)
            {
                if (refId.Id == ab.Id)
                {
                    reviewed = true;
                }
            }
            if (reviewed)
            {
                return(false);
            }
            Comment c = new Comment();

            c.TimeCommented = DateTime.Now;
            c.CommentedBy   = new MongoDBRef(this.GetType().ToString().ToLower(), this.Id);
            c.Text          = Text;
            ab.Comments.Insert(0, c);
            mongoDB.GetCollection <AudioBook>().Save(ab);
            this.ReviewdAB.Insert(0, new MongoDBRef(ab.GetType().ToString().ToLower(), ab.Id));
            this.GetCollection().Save(this);
            return(true);
        }
Пример #2
0
 public void approveBook(AudioBook ab)
 {
     ab.Approved   = true;
     ab.ApprovedBy = new MongoDBRef(this.GetType().ToString().ToLower(), this.Id);
     ab.Save();
     this.BooksApproved.Insert(0, new MongoDBRef("audiobook", ab.Id));
     this.GetCollection().Save(this);
 }
Пример #3
0
        public bool isReviewNarator(AudioBook ab)
        {
            bool reviewed = false;

            foreach (MongoDBRef refId in this.ReviewdAB)
            {
                if (refId.Id == ab.Id)
                {
                    reviewed = true;
                }
            }
            return(reviewed);
        }
Пример #4
0
        public bool isRatedBook(AudioBook ab)
        {
            bool voted = false;

            foreach (MongoDBRef refId in this.RatedAB)
            {
                if (refId.Id == ab.Id)
                {
                    voted = true;
                }
            }
            return(voted);
        }
Пример #5
0
 public bool rateAB(AudioBook ab, bool upVote)
 {
     if (isRatedBook(ab))
     {
         return(false);
     }
     if (upVote)
     {
         ab.Rating.Likes++;
     }
     else
     {
         ab.Rating.Dislikes++;
     }
     mongoDB.GetCollection <AudioBook>().Save(ab);
     this.RatedAB.Insert(0, new MongoDBRef(ab.GetType().ToString().ToLower(), ab.Id));
     this.GetCollection().Save(this);
     return(true);
 }
Пример #6
0
        public bool reviewNarator(AudioBook ab, string Text, int Rate)
        {
            if (isReviewNarator(ab))
            {
                return(false);
            }
            Review r = new Review();

            r.DateReviewd = DateTime.Now;
            r.ReviewedBy  = new MongoDBRef(this.GetType().ToString().ToLower(), this.Id);
            if (Text != null)
            {
                r.Explanation = Text;
            }
            r.Rating = Rate;
            ab.NaratorReview.Insert(0, r);
            mongoDB.GetCollection <AudioBook>().Save(ab);
            this.ReviewdAB.Insert(0, new MongoDBRef(ab.GetType().ToString().ToLower(), ab.Id));
            this.GetCollection().Save(this);
            return(true);
        }
Пример #7
0
        public void updateBook(string description, string bookPath, string imgPath, string Name, string Author, string Narator)
        {
            AudioBook ab = new AudioBook(Name, Author);

            ab.setBook(bookPath);
            if (imgPath != null)
            {
                ab.setCover(imgPath);
            }
            if (Narator != null)
            {
                ab.setNarator(Narator);
            }
            if (description != null)
            {
                ab.setDescription(description);
            }
            ab.UpdatedBy = new MongoDBRef(this.GetType().ToString().ToLower(), this.Id);
            ab.Save();

            this.UpdatedBook.Add(new MongoDBRef("audiobook", ab.Id));
            this.GetCollection().Save(this);
        }