public IActionResult GetMyActivities() { var myActivities = _allReadyDataAccess.GetActivitySignups(User.GetUserId()); var signedUp = myActivities.Select(a => new ActivityViewModel(a.Activity)); var viewModel = new MyActivitiesResultsScreenViewModel("My Activities", signedUp); return(View("MyActivities", viewModel)); }
public async Task <IActionResult> GetMyActivities() { var user = await GetCurrentUserAsync(); var myActivities = _allReadyDataAccess.GetActivitySignups(user); var signedUp = myActivities.Select(a => new ActivityViewModel(a.Activity)); var viewModel = new MyActivitiesResultsScreenViewModel("My Activities", signedUp); return(View("MyActivities", viewModel)); }
public static ActivityViewModel WithUserInfo(this ActivityViewModel viewModel, Activity activity, ClaimsPrincipal user, IAllReadyDataAccess dataAccess) { if (user.IsSignedIn()) { var userId = user.GetUserId(); var appUser = dataAccess.GetUser(userId); viewModel.UserId = userId; viewModel.UserSkills = appUser?.AssociatedSkills?.Select(us => us.Skill).ToList(); viewModel.IsUserVolunteeredForActivity = dataAccess.GetActivitySignups(viewModel.Id, userId).Any(); var assignedTasks = activity.Tasks.Where(t => t.AssignedVolunteers.Any(au => au.User.Id == userId)).ToList(); viewModel.UserTasks = new List <TaskViewModel>(assignedTasks.Select(data => new TaskViewModel(data, userId)).OrderBy(task => task.StartDateTime)); var unassignedTasks = activity.Tasks.Where(t => t.AssignedVolunteers.All(au => au.User.Id != userId)).ToList(); viewModel.Tasks = new List <TaskViewModel>(unassignedTasks.Select(data => new TaskViewModel(data, userId)).OrderBy(task => task.StartDateTime)); viewModel.SignupModel = new ActivitySignupViewModel() { ActivityId = viewModel.Id, UserId = userId, Name = appUser.Name, PreferredEmail = appUser.Email, PreferredPhoneNumber = appUser.PhoneNumber }; } else { viewModel.UserTasks = new List <TaskViewModel>(); } return(viewModel); }
public MyActivitiesResultsScreenViewModel Handle(GetMyActivitiesCommand message) { var myActivities = _allReadyDataAccess.GetActivitySignups(message.UserId).Where(a => !a.Activity.Campaign.Locked); var signedUp = myActivities.Select(a => new ActivityViewModel(a.Activity)).ToList(); return(new MyActivitiesResultsScreenViewModel("My Activities", signedUp)); }
public static ActivityViewModel WithUserInfo(this ActivityViewModel viewModel, Activity activity, ClaimsPrincipal user, IAllReadyDataAccess dataAccess) { if (user.IsSignedIn()) { var userId = user.GetUserId(); var appUser = dataAccess.GetUser(userId); viewModel.UserId = userId; viewModel.UserSkills = appUser?.AssociatedSkills?.Select(us => us.Skill).ToList(); viewModel.IsUserVolunteeredForActivity = dataAccess.GetActivitySignups(viewModel.Id, userId).Any(); var assignedTasks = activity.Tasks.Where(t => t.AssignedVolunteers.Any(au => au.User.Id == userId)).ToList(); viewModel.Tasks = new List<TaskViewModel>(assignedTasks.Select(data => new TaskViewModel(data, userId)).OrderBy(task => task.StartDateTime)); viewModel.SignupModel = new ActivitySignupViewModel() { ActivityId = viewModel.Id, UserId = userId, Name = appUser.Name, PreferredEmail = appUser.Email, PreferredPhoneNumber = appUser.PhoneNumber }; } else { viewModel.Tasks = new List<TaskViewModel>(); } return viewModel; }