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); }
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); }
public bool isReviewNarator(AudioBook ab) { bool reviewed = false; foreach (MongoDBRef refId in this.ReviewdAB) { if (refId.Id == ab.Id) { reviewed = true; } } return(reviewed); }
public bool isRatedBook(AudioBook ab) { bool voted = false; foreach (MongoDBRef refId in this.RatedAB) { if (refId.Id == ab.Id) { voted = true; } } return(voted); }
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); }
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); }
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); }