public ViewResult EditReview(int id) { var viewModel = new EditReviewViewModel() { Review = this.session.Repository<Review>().Get(id) }; return View("EditReview", viewModel); }
public ActionResult EditReview(EditReviewViewModel viewModel, HttpPostedFileBase image) { if (!ModelState.IsValid) return View(viewModel); if (image != null) { viewModel.Review.ImageMimeType = image.ContentType; viewModel.Review.Image = new byte[image.ContentLength]; image.InputStream.Read(viewModel.Review.Image, 0, image.ContentLength); } this.session.Repository<Review>().AddOrUpdate(viewModel.Review); this.session.Commit(); viewModel.Review.Image = null; return RedirectToAction("Reviews"); }
public ViewResult CreateReview() { var viewModel = new EditReviewViewModel() { Review = this.session.Repository<Review>().Create() }; viewModel.Review.AdditionDateTime = DateTime.Now; return View("EditReview", viewModel); }