Example #1
0
 public static void Delete(Review item)
 {
     try
     {
         var items = GetAll();
         var itemToDelete = items.Where(p => p.Id == item.Id).FirstOrDefault();
         items.Remove(itemToDelete);
         Add(items);
     }
     catch { }
 }
Example #2
0
        public static void Add(Review item)
        {
            try
            {
                var items = GetAll();

                if (items.Any(p => p.Id == item.Id || (p.UserId == item.UserId && p.Comment == item.Comment)))
                    return;

                items.Add(item);
                Add(items);
            }
            catch { }
        }
Example #3
0
        public ActionResult AddReview(string comment, int rating, Guid movieId)
        {
            var review = new Review
            {
                Id = Guid.NewGuid(),
                Comment = comment,
                MovieId = movieId,
                UserId = Helper.Users.Get(User.Identity.Name).Id,
                DateCreated = DateTime.Now,
                Rating = rating
            };

            Reviews.Add(review);

            return RedirectToAction("Detail", new { @id = movieId });
        }
Example #4
0
        public static void Update(Review item)
        {
            try
            {
                var items = GetAll();

                var oldItem = items.Where(p => p.Id == item.Id).FirstOrDefault();

                items.Remove(oldItem);
                items.Add(item);

                Add(items);
            }
            catch { }
        }