public ScheduleViewModel( ISessionDefinitionRepository sessionDefinitionRepository, IWorkOutAssignmentRepository workOutAssignmentRepository, IUserInterfaceState userInterfaceState) { _sessionDefinitionRepository = sessionDefinitionRepository; _workOutAssignmentRepository = workOutAssignmentRepository; _userInterfaceState = userInterfaceState; ViewNewSessionDefinitionForm = new RelayCommand(ViewNewSessionDefinitionFormExecute); EditSessionDefinition = new RelayCommand(EditSessionDefinitionExecute, CanEditSessionDefinitionExecute); ViewWorkOutDefinitionLibrary = new RelayCommand(ViewWorkOutDefinitionLibraryExecute); RemoveSelectedSessionDefinition = new RelayCommand(RemoveSelectedSessionDefinitionExecute); Sessions = new ObservableCollection <ISessionDefinitionViewModel>(_sessionDefinitionRepository.GetSessionDefinitions()); }
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()); } }