Esempio n. 1
0
        public ActionResult Rate(int id)
        {
            var service = CreateRetreatService();

            ViewBag.Detail = service.GetRetreatById(id);

            var model = new RetreatRatingCreate {
                RetreatId = id
            };

            return(View(model));
        }
Esempio n. 2
0
        //Rate a retreat
        public bool CreateRetreatRating(RetreatRatingCreate model)
        {
            var entity = new RetreatRating
            {
                Description = model.Description,
                RetreatId   = model.RetreatId,
                MyRating    = model.MyRating,
                UserId      = _userId.ToString()
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Ratings.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Esempio n. 3
0
        public ActionResult Rate(RetreatRatingCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new RatingService(Guid.Parse(User.Identity.GetUserId()));

            if (service.CreateRetreatRating(model))
            {
                TempData["SaveResult"] = "Your retreat was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Retreat could not be created.");
            return(View(model));
        }