public WorkOutAssignment[] GetAssignments(ISessionDefinitionViewModel sessionDefinitionViewModel) { using (var connection = DependencyService.Get <ISQLite>().GetConnection()) { var workoutDefinitions = _workoutDefinitionRepository.GetWorkOutDefinitions(); return(connection.Query <WorkOutAssignmentRow>("SELECT * FROM WorkOutAssignment WHERE SessionDefinitionId = ?", sessionDefinitionViewModel.SessionDefinitonId) .Select(s => new WorkOutAssignment { SessionDefinitionId = s.SessionDefinitionId, SessionDefinition = sessionDefinitionViewModel, WorkOutDefinitionId = s.WorkOutDefinitionId, WorkoutType = (WorkOutAssignment.WorkOutTypes)s.WorkOutType, WorkOutDefinition = workoutDefinitions.First(f => f.WorkOutId == s.WorkOutDefinitionId) }) .ToArray()); } }
public IWorkoutViewModel[] GetWorkOuts(ISessionViewModel session) { var sessionDefinition = _sessionDefinitionRepository .GetSessionDefinitions() .First(f => f.SessionDefinitonId == session.SessionDefinitionId); var assignments = _workoutAssignmentRepository.GetAssignments(sessionDefinition); var workOutDefinitions = _workOutDefinitionRepository.GetWorkOutDefinitions(assignments); using (var connection = DependencyService.Get <ISQLite>().GetConnection()) { return(connection .Query <WorkOutRow>("SELECT * FROM WorkOut WHERE SessionId = ?", session.SessionId) .Select(workOut => CreateWorkOutFromWorkOutRow(workOut, workOutDefinitions.FirstOrDefault(f => f.WorkOutId == workOut.WorkOutDefinitionId))) .ToArray()); } }
public WorkOutDefinitionLibraryViewModel(IWorkOutDefinitionRepository workoutDefinitionRepository, IUserInterfaceState userInterfaceState) { _workOutDefinitionRepository = workoutDefinitionRepository; _userInterfaceState = userInterfaceState; WorkOutDefinitions = new ObservableCollection <IWorkoutDefinitionViewModel>(workoutDefinitionRepository.GetWorkOutDefinitions()); ViewWorkoutDefinition = new RelayCommand(ViewWorkoutDefinitionExecute, CanViewWorkoutDefinitionExecute); AddWorkoutDefinition = new RelayCommand(AddWorkOutDefinitionExecute); RemoveWorkoutDefinition = new RelayCommand(RemoveSelectedWorkoutDefinitionExecute, CanRemoveSelectedWorkoutDefinition); }