Beispiel #1
0
        public void GetRatingForSessionJavaOne2015_ShouldReturnExpected()
        {
            var expected = 3.7;

            var result = _utilityManager.GetRatingForSessionById(1);

            Assert.AreEqual(expected, result);
        }
        public ActionResult SessionForActivity(int id)
        {
            var theSession = _sessionManager.GetSessionByIdWithIncludes(id);

            if (theSession == null)
            {
                return(View("Error"));
            }

            var allParticipant =
                _personManager.GetAllParticipantsForSession(id).OrderBy(n => n.FirstName).ToList();
            var allTagsForSession =
                _utilityManager.GetAllTagsForSessionById(id).ToList();
            var sessionRating =
                _utilityManager.GetRatingForSessionById(id);
            var loggedInUser =
                _personManager.GetParticipantByCas(User.Identity.Name.ToCasId());
            bool userHasExpressedInterest = _personManager.GetASessionParticipant(theSession.Id, loggedInUser.Id) != null;

            var rawReviews = theSession.SessionParticipants.Where(n => n.Rating != 0);
            var reviews    = new List <Review>();

            foreach (var rawReview in rawReviews)
            {
                reviews.Add(new Review()
                {
                    Rating   = rawReview.Rating,
                    Name     = _personManager.GetParticipantById(rawReview.ParticipantId).FullName,
                    Comments = rawReview.Comments
                });
            }

            var result = new SessionForActivityViewModel
            {
                Comments    = theSession.Comments,
                Evaluation  = theSession.Evaluation,
                StartDate   = theSession.StartDate,
                EndDate     = theSession.EndDate,
                Description = theSession.Description,
                IsOpenForExpressionOfInterest = theSession.IsOpenForExpressionOfInterest,
                HrPerson                = theSession.HrPerson,
                Location                = theSession.Location,
                TotalPaticipants        = allParticipant.Count,
                Participants            = allParticipant,
                SessionNameWithActivity = theSession.NameWithActivity,
                SessionId               = id,
                ActivityName            = theSession.Activity.Name,
                ActivityId              = theSession.ActivityId,
                Tags    = allTagsForSession,
                Rating  = sessionRating.ToString(CultureInfo.CreateSpecificCulture("en-US")),
                Reviews = reviews,
                UserHasExpressedInterest = userHasExpressedInterest
            };

            return(View(result));
        }
Beispiel #3
0
        public ViewResult RatingStatistics()
        {
            var allSessionsWithReviews = _sessionManager.GetAllSessionsWithReviews().ToList();

            var result = new List <RatingStatisticsViewModel>();

            foreach (var session in allSessionsWithReviews)
            {
                result.Add(new RatingStatisticsViewModel()
                {
                    Session     = session,
                    Rating      = _utilityManager.GetRatingForSessionById(session.Id),
                    NoOfRatings = session.SessionParticipants.Count(n => n.SessionId == session.Id && n.Rating != 0)
                });
            }

            return(View(result));
        }
        public void TopRatedSession_ShouldBeJavaOne2015()
        {
            var allSessionsWithReviews = _sessionManager.GetAllSessionsWithReviews().ToList();

            var ratingStatistics = new List <RatingStatistics>();

            foreach (var session in allSessionsWithReviews)
            {
                ratingStatistics.Add(new RatingStatistics()
                {
                    Session = session,
                    Rating  = _utilityManager.GetRatingForSessionById(session.Id)
                });
            }

            var topRatedSession = ratingStatistics.OrderByDescending(n => n.Rating).Take(1).SingleOrDefault();

            var expected = _sessionManager.GetSessionById(1);

            Assert.AreEqual(expected, topRatedSession.Session);
        }