public async Task <IViewComponentResult> InvokeAsync(int movieId)
        {
            var movie = await db.Movie.FindAsync(movieId);

            var doubleRating = (int)Math.Round(movie.Rating * 2);
            var model        = new StarsViewModel
            {
                Stars    = doubleRating / 2,
                HalfStar = doubleRating % 2 == 1
            };

            return(View(model));
        }
Example #2
0
        public async Task <IViewComponentResult> InvokeAsync(int movieId)
        {
            var movie = await db.Movie.FindAsync(movieId);

            var rating = movie.Rating;

            var doubleRating = (int)Math.Round(rating * 2);
            var model        = new StarsViewModel
            {
                Stars    = doubleRating / 2,
                HalfStar = doubleRating % 2 == 1
            };


            return(View(model)); //implicit vyn Default.cshtml i Shared/Stars
        }