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 { } }
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 { } }
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 }); }
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 { } }