예제 #1
0
        public ActivityModel(Activity activityData)
        {
            if (activityData == null)
            {
                return;
            }

            Id = activityData.Id;
            Name = activityData.Name;
            OrganizingTeam = activityData.OrganizingTeam == null ? "" : activityData.OrganizingTeam.Name;
            DateFormatted = activityData.Date.ToSwedishShortDateString();
            Summary = activityData.Summary;
        }
        public void CanAddSessionToActivity()
        {
            var actMock = new Mock<IActivityRepository>();
            var repoMock = new Mock<ISessionRepository>();
            Activity activity = new Activity(){Id = 145};

            var controller = CreateController(actMock.Object, repoMock.Object);
            repoMock.Setup(r => r.Save(145, null));
            var activitySessionsModel = new ActivitySessionsModel(new ActivityModel(activity), new List<SessionModel>());

            RedirectToRouteResult result = (RedirectToRouteResult) controller.Save(activitySessionsModel);

            Assert.IsNotNull( result );
            Assert.AreEqual( "Index", result .RouteValues["Action"] );
            Assert.AreEqual( 145, result.RouteValues["activityId"] );
        }
 protected override void StoreActivity(Activity activity)
 {
     CreatedActivity = activity;
 }
 public SignedForActivityViewModel(Activity activityData, User user)
     : base(activityData, user)
 {
     Session = activityData.Sessions;
 }
예제 #5
0
        private MailData NewEventText(Activity activity, EmailType emailType, string freeText)
        {
            var templateName = "";
            switch (emailType)
            {
                case EmailType.None:
                    return null;
                case EmailType.NewActivity:
                    templateName = "newactivity";
                    break;
                case EmailType.InfoActivity:
                    templateName = "infoactivity";
                    break;
            }

            var data = new Dictionary<string, object>
                {
                    {"ActivityName", activity.Name},
                    {"Team", activity.OrganizingTeam.Name},
                    {"Date", activity.Date.ToString("yyyy-MM-dd")},
                    {"Summary", activity.Summary},
                    {"Description", activity.Description},
                    {"ActivityManager", activity.Coordinator.Name}
                };

            if (activity.Sessions != null)
            {
                data.Add("FirstTime", activity.Sessions.OrderBy(s => s.FromTime).First().FromTime.ToString("hh':'mm"));
                data.Add("LastTime", activity.Sessions.OrderByDescending(s => s.ToTime).First().ToTime.ToString("hh':'mm"));

                var usersAndPasses = activity.Sessions.SelectMany(s => s.Volunteers).Distinct().OrderBy(u => u.Name).Select(u => new
                    {
                        u.Name,
                        u.Cellphone,
                        Sessions = u.Sessions.Where(s => s.Activity != null && s.Activity.Id == activity.Id).OrderBy(s => s.FromTime).Select(s => new
                            {
                                FromTime = s.FromTime.ToString("hh':'mm"),
                                ToTime = s.ToTime.ToString("hh':'mm")
                            })
                    });
                data.Add("Users", usersAndPasses);
            }

            if (!string.IsNullOrWhiteSpace(freeText))
            {
                data.Add("FreeText", freeText.Replace("\n", "<br/>"));
            }

            return _templateService.RenderTemplate(templateName, data);
        }
 Session SetupRepoWithSession(Mock<IActivityRepository> aMock, Mock<ISessionRepository> mock, int activityId)
 {
     var activity = new Activity { Id = activityId, Name = "foo", Date = new DateTime( 2023, 11, 12 ) };
     var session = new Session
     {
         Id = 223,
         Activity = activity,
         FromTime = activity.Date.AddHours( 1 ).TimeOfDay,
         ToTime = activity.Date.AddHours( 2 ).TimeOfDay,
         VolunteersNeeded = 33
     };
     mock.Setup( r => r.GetSessionsForActivity( activityId ) ).Returns( () => new List<Session> { session } );
     aMock.Setup(r => r.GetActivityById(activityId)).Returns(activity);
     return session;
 }
예제 #7
0
 public LandingPageModel()
 {
     Activities = new Activity[] { };
     Teams = new Team[] { };
 }