Beispiel #1
0
        public void CreateSession_ShouldAddThatSession()
        {
            // Arrange
            var controller = new SessionController(_activityManager, _sessionManager, _personManager, _utilityManager);

            var sessionToAdd = new CreateSessionViewModel()
            {
                Activity          = _activityManager.GetActivityById(1),
                Name              = "New Session",
                AddedParticipants = "1,2",
                AddedTags         = "5,6",
                NameOfLocation    = "New Location"
            };

            // Act
            var controllerResult = controller.CreateSession(sessionToAdd);

            var sessionID = _sessionManager.GetAllSessions().SingleOrDefault(n => n.Name == "New Session").Id;
            var result    = _sessionManager.GetSessionByIdWithIncludes(sessionID);

            var tags = new string[2];

            tags[0] = "databaser";
            tags[1] = "sql";

            //TODO: check that it's the correct sessionparticipants & tags!?

            // Assert
            Assert.AreEqual(2, result.SessionParticipants.Count);
            Assert.AreEqual(2, result.SessionTags.Count);
        }
        public ActionResult AllSessionsForActivity(int id)
        {
            var allSessionsForActivity = _sessionManager
                                         .GetAllSessionsWithIncludes()
                                         .Where(n => n.ActivityId == id)
                                         .ToList();
            var activityName = _activityManager.GetActivityById(id).Name;

            var viewModel = new AllSessionsForActivityViewModel
            {
                ActivityId   = id,
                ActivityName = activityName,
                Sessions     = allSessionsForActivity
            };

            return(View(viewModel));
        }
Beispiel #3
0
        public ActionResult EditActivity(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var activity = _activityManager.GetActivityById(id.Value);

            if (activity == null)
            {
                return(HttpNotFound());
            }
            var result = new ActivityViewModel {
                Name = activity.Name
            };

            return(View(result));
        }
        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));
        }
Beispiel #5
0
        public void GetActivityById2_ShouldReturnJavaOne()
        {
            var result = _activityManager.GetActivityById(2);

            Assert.AreEqual("JavaOne", result.Name);
        }