예제 #1
0
        public async Task <IActionResult> Details(string rating, Experience exp, string comment)
        {
            string      idu  = userManager.GetUserId(User);
            Utilisateur user = await userService.GetUtilisateurByIdAsync(idu);

            var experience = await ExperienceService.GetById(exp.ExperienceId);

            if (rating != null)
            {
                await ratingService.Rater(experience, user, rating);

                ViewBag.avg = ratingService.Moyen(exp.ExperienceId);

                var x = await ratingService.Moyen(exp.ExperienceId);

                experience.AvgRating = x.ToString();
                await ExperienceService.PutExperienceAsync(experience.ExperienceId, experience);
            }
            if (comment != null)
            {
                await ratingService.Commenter(experience, user, comment);
            }
            if (exp == experience)
            {
                return(NotFound());
            }

            return(RedirectToAction("GetAll"));
        }