Example #1
0
        public ActionResult Rate(int id)
        {
            var service = CreateCenterService();

            ViewBag.Detail = service.GetCenterById(id);

            var model = new CenterRatingCreate {
                CenterId = id
            };

            return(View(model));
        }
Example #2
0
        //Rate a center
        public bool CreateCenterRating(CenterRatingCreate model)
        {
            var entity = new CenterRating
            {
                Description = model.Description,
                CenterId    = model.CenterId,
                MyRating    = model.MyRating,
                VisitDate   = model.VisitDate,
                UserId      = _userId.ToString()
            };

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

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

            if (service.CreateCenterRating(model))
            {
                TempData["SaveResult"] = "Your rating was added.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Rating could not be added.");
            return(View(model));
        }