Пример #1
0
        public void UnassignWorkOutDefinition(IWorkoutAssignment workOutAssignment)
        {
            using (var connection = DependencyService.Get <ISQLite>().GetConnection())
            {
                var assignments = connection
                                  .Query <WorkOutAssignmentRow>("SELECT * FROM WorkOutAssignment WHERE WorkOutDefinitionId = ? AND SessionDefinitionId = ? AND WorkOutType = ?",
                                                                workOutAssignment.WorkOutDefinition.WorkOutId,
                                                                workOutAssignment.SessionDefinitionId,
                                                                workOutAssignment.WorkoutType);

                foreach (var assignment in assignments)
                {
                    connection.Delete(assignment);
                }
            }
        }
Пример #2
0
        public void AssignWorkOutDefinition(IWorkoutAssignment workOutAssignment)
        {
            using (var connection = DependencyService.Get <ISQLite>().GetConnection())
            {
                var workoutDefinitions = _workoutDefinitionRepository.GetWorkOutDefinitions();

                var workOutDefinitionMap = new WorkOutAssignmentRow
                {
                    SessionDefinitionId = workOutAssignment.SessionDefinitionId,
                    WorkOutDefinitionId = workOutAssignment.WorkOutDefinition.WorkOutId,
                    WorkOutType         = (int)workOutAssignment.WorkoutType
                };

                connection.Insert(workOutDefinitionMap);

                workOutAssignment.WorkOutDefinition = workoutDefinitions.First(f => f.WorkOutId == workOutAssignment.WorkOutDefinition.WorkOutId);
            }
        }
        private static IWorkoutViewModel CreateWorkOut(IWorkoutAssignment assignment)
        {
            var workoutDefintion = assignment.WorkOutDefinition;

            var sets = CreateWarmUpSetsFromWorkOutDefinition(workoutDefintion);

            sets.AddRange(CreateSetsFromWorkOutDefinition(workoutDefintion));

            var workoutViewModel = App.Container.Resolve <IWorkoutViewModel>();

            workoutViewModel.WorkOutName         = workoutDefintion.WorkOutName;
            workoutViewModel.WorkOutDefinitionId = workoutDefintion.WorkOutId;
            workoutViewModel.WorkOutType         = assignment.WorkoutType;
            foreach (var set in sets)
            {
                workoutViewModel.WorkOutSets.Add(set);
            }
            return(workoutViewModel);
        }
 private void RemoveSelectedWorkOutDefinitionExecute()
 {
     WorkOutDefinitions.Remove(SelectedWorkOutDefinition);
     _workOutAssignmentRepository.UnassignWorkOutDefinition(SelectedWorkOutDefinition);
     SelectedWorkOutDefinition = null;
 }