Exemplo n.º 1
0
 public ActionResult Create(int albumId,FormCollection form)
 {
     var review = new Review();
     review.Member = db.Members.Where(m => m.Email == User.Identity.Name).FirstOrDefault();
     review.Album = db.Albums.Find(albumId);
     review.ReviewDate = DateTime.Now;
     if (TryUpdateModel<Review>(review))
     {
         db.Reviews.Add(review);
         db.SaveChanges();
         return RedirectToAction("Detail", "Album", new { id = albumId });
     }
     ViewData["AlbumTitle"] = review.Album.Name;
     return View();
 }
Exemplo n.º 2
0
 public ActionResult Edit(Review review)
 {
     if (ModelState.IsValid)
     {
         Review oldReview = db.Reviews.Find(review.Id);
         oldReview.Rating = review.Rating;
         oldReview.Comment = review.Comment;
         oldReview.ReviewDate = DateTime.Now;
         db.SaveChanges();
         return RedirectToAction("Detail", "Album", new { id = oldReview.Album.Id });
     }
     return View(review);
 }