예제 #1
0
        public void TagsForSessionId1_ShouldReturnExpected()
        {
            var expectedCount = 3;

            var resultCount = _utilityManager.GetAllTagsForSessionById(1).Count();

            Assert.AreEqual(expectedCount, resultCount);
        }
예제 #2
0
        public ActionResult EditSession(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var session = _sessionManager.GetSessionByIdWithIncludes((int)id);

            if (session == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var activity = _activityManager.GetActivityById(session.ActivityId);

            // Get Tags for session
            var allTagsForSession =
                _utilitiesManager.GetAllTagsForSessionById((int)id).ToList();

            var viewModel = new EditSessionViewModel()
            {
                SessionId = session.Id,
                NameOfSessionWithActivity = session.NameWithActivity,
                Activity      = activity,
                NameOfSession = session.Name,
                StartDate     = session.StartDate,
                EndDate       = session.EndDate,
                Description   = session.Description,
                IsOpenForExpressionOfInterest = session.IsOpenForExpressionOfInterest,
                HrPerson       = session.HrPersonId,
                NameOfLocation = (session.Location == null) ? string.Empty : session.Location.Name,
                AddedTags      = allTagsForSession
            };

            ViewBag.NameOfLocation = viewModel.NameOfLocation;

            ViewBag.AllHrPersons = new SelectList(_personManager.GetAllHrPersons().OrderBy(n => n.FirstName), "Id",
                                                  "FullName", session.HrPersonId);
            ViewBag.AllActivities = new SelectList(_activityManager.GetAllActivities().OrderBy(n => n.Name), "Id",
                                                   "Name", session.ActivityId);

            return(View(viewModel));
        }
        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));
        }
예제 #4
0
        public void UseCase4_RemoveSessionJavaOne2015_ShouldDeleteAllSessionTagsForJavaOne2015()
        {
            // 1. DELETE ALL SESSIONS
            _sessionManager.DeleteSessionById(1);

            // 2. GET THE COUNT FOR SESSIONTAGS
            var resultCount = _utilityManager.GetAllTagsForSessionById(1).Count();

            var expectedCount = 0;

            Assert.AreEqual(expectedCount, resultCount);
        }