private void ShowSessionDetail(ISessionViewModel session) { MessagingCenter.Send(new NavigationMessage { Parameter = session }, Enums.eNavigationMessage.ShowSessionDetailPage.ToString()); }
internal void Initialize(ISessionViewModel sessionViewModel, WizardBuilder builder) { var steps = builder.Build(ID); var linkedSteps = new LinkedList <NovaStep>(steps); Initialize(sessionViewModel, linkedSteps.First); }
public void Create_workouts_from_assigned_workout_definitions() { ISessionViewModel session = null; var sessionRepository = _fixture.Freeze <Mock <ISessionRepository> >(); var workoutRepository = _fixture.Freeze <Mock <IWorkOutRepository> >(); sessionRepository.Setup(s => s.AddSession(It.IsAny <ISessionViewModel>())) .Callback <ISessionViewModel>(c => { session = c; }); workoutRepository.Setup(s => s.AddWorkOut(It.IsAny <IWorkoutViewModel>())) .Callback <IWorkoutViewModel>(c => { Assert.IsTrue(session.SessionWorkOuts.Count(e => e == c) == 1); }); var sut = _fixture.Create <CreateNextSessionViewModel>(); sut.CreateNextSession.Execute(null); foreach (var workout in session.SessionWorkOuts) { var workoutAssignment = sut.SelectedSessionDefinition.WorkOutDefinitions.First(f => f.WorkOutDefinition.WorkOutId == workout.WorkOutDefinitionId); var workoutDefinition = workoutAssignment.WorkOutDefinition; Assert.AreEqual(workout.WorkOutDefinitionId, workoutDefinition.WorkOutId); Assert.AreEqual(workout.WorkOutName, workoutDefinition.WorkOutName); Assert.AreEqual(workout.WorkOutType, workoutAssignment.WorkoutType); } }
public SessionDetailPage(ISessionViewModel session) { _session = session; NavigationPage.SetHasNavigationBar(this, false); InitializeComponent(); }
public void AddSession(ISessionViewModel session) { using (var connection = DependencyService.Get <ISQLite>().GetConnection()) { var sessionRow = new SessionRow { SessionDefinitionId = session.SessionDefinitionId, SessionName = session.SessionName, SessionDate = session.SessionDate }; connection.Insert(sessionRow); session.SessionId = sessionRow.SessionId; foreach (var workout in session.SessionWorkOuts) { workout.SessionId = session.SessionId; _workoutRepository.AddWorkOut(workout); foreach (var set in workout.WorkOutSets) { set.WorkOutId = workout.WorkOutId; _setRepository.AddSet(set); } } } }
private void RemoveSelectedSessionExecute() { Sessions.Remove(SelectedSession); _sessionRepository.DeleteSession(SelectedSession); SelectedSession = null; }
private void CloseSession(ISessionViewModel sessionViewModel) { sessionViewModel.Receiver.Deactivate(); foreach (var analysis in sessionViewModel.Analysis) { analysis.Deactivate(); } _informationEngine.DeleteSession(sessionViewModel.SessionId); }
public void Create_sets_from_assigned_workout_definitions() { ISessionViewModel session = null; var sessionRepository = _fixture.Freeze <Mock <ISessionRepository> >(); var workoutRepository = _fixture.Freeze <Mock <IWorkOutRepository> >(); var setRepository = _fixture.Freeze <Mock <ISetRepository> >(); sessionRepository.Setup(s => s.AddSession(It.IsAny <ISessionViewModel>())) .Callback <ISessionViewModel>(c => { session = c; }); workoutRepository.Setup(s => s.AddWorkOut(It.IsAny <IWorkoutViewModel>())) .Callback <IWorkoutViewModel>(c => { Assert.IsTrue(session.SessionWorkOuts.Count(e => e == c) == 1); }); setRepository.Setup(s => s.AddSet(It.IsAny <ISetViewModel>())) .Callback <ISetViewModel>(newValue => { Assert.IsTrue(session.SessionWorkOuts.SelectMany(s => s.WorkOutSets).Count(c => c == newValue) == 1); }); var sut = _fixture.Create <CreateNextSessionViewModel>(); sut.CreateNextSession.Execute(null); foreach (var workout in session.SessionWorkOuts) { var workoutAssignment = sut.SelectedSessionDefinition.WorkOutDefinitions.First(f => f.WorkOutDefinition.WorkOutId == workout.WorkOutDefinitionId); var workoutDefinition = workoutAssignment.WorkOutDefinition; Assert.AreEqual(workoutDefinition.NumberOfSets, workout.WorkOutSets.Count(c => c.SetType == WorkOutAssignment.WorkOutTypes.MainWorkout)); Assert.AreEqual(workoutDefinition.NumberOfWarmUpSets, workout.WorkOutSets.Count(c => c.SetType == WorkOutAssignment.WorkOutTypes.WarmUpWorkout)); foreach (var warmupSet in workout.WorkOutSets .Where(w => w.SetType == WorkOutAssignment.WorkOutTypes.WarmUpWorkout)) { Assert.AreEqual(workoutDefinition.WarmUpRepetitions, warmupSet.TotalRepetitions); Assert.AreEqual(workoutDefinition.WarmUpWeight, warmupSet.Weight); } foreach (var set in workout.WorkOutSets .Where(w => w.SetType == WorkOutAssignment.WorkOutTypes.MainWorkout)) { Assert.AreEqual(workoutDefinition.Repetitions, set.TotalRepetitions); Assert.AreEqual(workoutDefinition.Weight, set.Weight); } } }
public void UpdateSession(ISessionViewModel session) { using (var connection = DependencyService.Get <ISQLite>().GetConnection()) { connection.Update(new SessionRow { SessionId = session.SessionId, SessionDefinitionId = session.SessionDefinitionId, SessionName = session.SessionName, SessionDate = session.SessionDate }); } }
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()); } }
private void StartNewSession() { var dialog = new NewSessionDialog { Owner = Application.Current.MainWindow }; if (dialog.ShowDialog() == true) { var newSessionId = _informationEngine.AddSession(dialog.ViewModel.SelectedReceiver, dialog.ViewModel.SelectedAnalysis); SelectedSessionViewModel = SessionViewModels.Single(x => x.SessionId == newSessionId); InitializeReceiverCommand.Execute(new Tuple <Guid, IReceiver>(SelectedSessionViewModel.SessionId, SelectedSessionViewModel.Receiver)); } }
internal void Initialize(ISessionViewModel sessionViewModel, LinkedListNode <NovaStep> initialView) { using (_deferral) { if (sessionViewModel == null) { throw new ArgumentNullException("sessionViewModel"); } if (initialView == null) { throw new ArgumentNullException("initialView"); } SessionViewModel = sessionViewModel; InitialView = initialView; } _deferral = null; }
public void DeleteSession(ISessionViewModel session) { using (var connection = DependencyService.Get <ISQLite>().GetConnection()) { connection.Delete <SessionRow>(session.SessionId); if (session.SessionWorkOuts != null) { foreach (var workOut in session.SessionWorkOuts) { if (workOut.WorkOutSets != null) { foreach (var set in workOut.WorkOutSets) { _setRepository.DeleteSet(set); } } _workoutRepository.DeleteWorkOut(workOut); } } } }
public void Create_next_session_from_selected_session_definition() { ISessionViewModel session = null; var sessionLogViewModel = _fixture.Freeze <Mock <ISessionLogViewModel> >(); var sessionRepository = _fixture.Freeze <Mock <ISessionRepository> >(); sessionRepository.Setup(s => s.AddSession(It.IsAny <ISessionViewModel>())) .Callback <ISessionViewModel>(c => { session = c; }); var sut = _fixture.Create <CreateNextSessionViewModel>(); sut.CreateNextSession.Execute(null); Assert.IsNotNull(session); Assert.AreEqual(sut.SelectedSessionDefinition.SessionDefinitonId, session.SessionDefinitionId); Assert.IsNotNull(session.SessionDate); Assert.AreEqual(DateTime.Now.DayOfYear, session.SessionDate.DayOfYear); Assert.AreSame(session, sessionLogViewModel.Object.Sessions.First(f => f.SessionId == session.SessionId)); Assert.AreEqual(sut.SelectedSessionDefinition.SessionName, session.SessionName); }
/// <summary> /// Initializes a new instance of the <see cref="MultiStepView" /> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="sessionViewModel">The session view model.</param> /// <param name="groupId">The group id.</param> /// <param name="initialView"></param> /// <exception cref="System.ArgumentNullException">steps</exception> /// <exception cref="System.ArgumentException">@Steps cannot be empty.;steps</exception> public MultiStepView(IView parent, ISessionViewModel sessionViewModel, Guid groupId, LinkedListNode <NovaStep> initialView) { if (parent == null) { throw new ArgumentNullException("parent"); } if (sessionViewModel == null) { throw new ArgumentNullException("sessionViewModel"); } if (initialView == null) { throw new ArgumentNullException("initialView"); } _parent = parent; _groupId = groupId; _sessionViewModel = sessionViewModel; SnapsToDevicePixels = true; FocusVisualStyle = null; TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType); TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality); VisualTextRenderingMode = TextRenderingMode.ClearType; var stepInfos = initialView.List.Select(x => new StepInfo(x.Title, x.ViewType, x.ViewModelType, x.NodeId)); _steps = new LinkedList <StepInfo>(stepInfos); CurrentView = initialView; }
private void CloseSession(ISessionViewModel sessionViewModel) { sessionViewModel.Receiver.Deactivate(); foreach (var analysis in sessionViewModel.Analysis) { analysis.Deactivate(); } _informationEngine.DeleteSession(sessionViewModel.SessionId); }
public SessionDetailView(ISessionLogViewModel sessionLogViewModel) { InitializeComponent(); _session = sessionLogViewModel.SelectedSession; }