コード例 #1
0
        public ActionResult Create(CreateReview formModel, int Id)
        {
            var email = User.Identity.Name;

            var revRepo  = new ReviewsRepo(context);
            var benRepo  = new BenchRepo(context);
            var userRepo = new UserRepo(context);

            try
            {
                Bench bench  = benRepo.GetById(Id);
                User  user   = userRepo.GetByEmail(email);
                var   review = new Review(formModel.Rating, formModel.Comment, bench, user);
                review.CreatedOn = DateTime.UtcNow;
                revRepo.Insert(review);
                return(RedirectToAction("Index", "Bench"));
            }
            catch (DbUpdateException ex)
            {
                //HandleDbUpdateException(ex);
            }

            return(View("Create", formModel));
        }