public EventViewModel Handle(ShowEventQuery message)
        {
            var campaignEvent = _dataAccess.GetEvent(message.EventId);

            if (campaignEvent == null || campaignEvent.Campaign.Locked)
            {
                return(null);
            }

            return(new EventViewModel(campaignEvent)
                   .WithUserInfo(campaignEvent, message.User, _dataAccess));
        }
Beispiel #2
0
        public EventViewModel Handle(ShowEventQuery message)
        {
            var @event = _dataAccess.GetEvent(message.EventId);

            if (@event == null || @event.Campaign.Locked)
            {
                return(null);
            }

            var eventViewModel = new EventViewModel(@event);

            var userId  = _userManager.GetUserId(message.User);
            var appUser = _dataAccess.GetUser(userId);

            eventViewModel.UserId     = userId;
            eventViewModel.UserSkills = appUser?.AssociatedSkills?.Select(us => new SkillViewModel(us.Skill)).ToList();
            eventViewModel.IsUserVolunteeredForEvent = _dataAccess.GetEventSignups(eventViewModel.Id, userId).Any();

            var assignedTasks = @event.Tasks.Where(t => t.AssignedVolunteers.Any(au => au.User.Id == userId)).ToList();

            eventViewModel.UserTasks = new List <TaskViewModel>(assignedTasks.Select(data => new TaskViewModel(data, userId)).OrderBy(task => task.StartDateTime));

            var unassignedTasks = @event.Tasks.Where(t => t.AssignedVolunteers.All(au => au.User.Id != userId)).ToList();

            eventViewModel.Tasks = new List <TaskViewModel>(unassignedTasks.Select(data => new TaskViewModel(data, userId)).OrderBy(task => task.StartDateTime));

            eventViewModel.SignupModel = new EventSignupViewModel
            {
                EventId              = eventViewModel.Id,
                UserId               = userId,
                Name                 = appUser?.Name,
                PreferredEmail       = appUser?.Email,
                PreferredPhoneNumber = appUser?.PhoneNumber
            };

            return(eventViewModel);
        }
Beispiel #3
0
 public Models.Event Handle(EventByIdQuery message)
 {
     return(dataAccess.GetEvent(message.EventId));
 }