public void CompareInEqaulityFalse_ReturnsFalse()
        {
            var fake1 = ExerciseSet.FakeFactory();
            var fake2 = ExerciseSet.FakeFactory();

            Assert.That((fake1 != fake2), Is.False);
        }
Example #2
0
 public CrossfitViewModel(CrossfitWorkoutDBModel model)
 {
     exerciseSet_      = new ExerciseSet(model.BreakBetweenExercises, model.ExerciseTime, model.QuedExercises.Split('_'));
     breakBetweenSets_ = model.BreakBetweenSets;
     sets_             = model.Sets;
     Id = model.Id.Value;
 }
Example #3
0
 public ExerciseSetModel(ExerciseSet exerciseSet)
 {
     ExerciseSetId = exerciseSet.ExerciseSetId;
     Reps          = exerciseSet.Reps;
     Weight        = exerciseSet.Weight;
     OrderId       = exerciseSet.OrderId;
 }
Example #4
0
        // POST: odata/ExerciseSets
        public async Task <IHttpActionResult> Post(ExerciseSet exerciseSet)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ExerciseSets.Add(exerciseSet);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ExerciseSetExists(exerciseSet.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(exerciseSet));
        }
        public void CompareObjectEquals_ReturnsTrue()
        {
            var fake1 = ExerciseSet.FakeFactory();
            var fake2 = ExerciseSet.FakeFactory();

            Assert.That(fake1.Equals(fake2), Is.True);
        }
        public void CompareEquality_ReturnsTrue()
        {
            var fake1 = ExerciseSet.FakeFactory();
            var fake2 = ExerciseSet.FakeFactory();

            Assert.That(fake1, Is.EqualTo(fake2));
            Assert.That((fake1 == fake2), Is.True);
        }
Example #7
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            var parent = sender as Button;

            exSet     = parent.BindingContext as ExerciseSet;
            TapCount += 1;
            TapSubject.OnNext(TapCount);
        }
        public void CompareObjectEqualityFalse_ReturnsFalse()
        {
            var fake1 = ExerciseSet.FakeFactory();
            var fake2 = ExerciseSet.FakeFactory();

            fake2.Repetitions = fake1.Repetitions + 1;
            Assert.That(fake1.Equals(fake2), Is.False);
        }
        public void CompareInequality_ReturnsTrue()
        {
            var fake1 = ExerciseSet.FakeFactory();
            var fake2 = ExerciseSet.FakeFactory();

            fake2.Repetitions = fake1.Repetitions + 1; // Make fake 2 different.

            Assert.That(fake1 != fake2, Is.True);
        }
Example #10
0
        public void GetTotalRepsForDay()
        {
            var plan = new DiscreteExercisePlan(true);

            Assert.That(plan.GetTotalRepsForDay(DateTime.Parse("01/01/2000")), Is.EqualTo(50));

            plan.SetsOfExercise.Add(ExerciseSet.FakeFactory());
            Assert.That(plan.GetTotalRepsForDay(DateTime.Parse("01/01/2000")), Is.EqualTo(55));
        }
Example #11
0
        public void GetSetsForDay_Returns2()
        {
            var plan = new DiscreteExercisePlan(true);

            plan.SetsOfExercise.Add(ExerciseSet.FakeFactory());

            var list = plan.GetSetsForDay(DateTime.Parse("01/01/2000"));

            Assert.That(list.Count, Is.EqualTo(2));
        }
Example #12
0
        private UserExerciseSet CreateExerciseSet(ExerciseSet exerciseSet)
        {
            var set = new UserExerciseSet
            {
                Id          = Guid.NewGuid(),
                Number      = exerciseSet.Number,
                Repetitions = exerciseSet.Repetitions,
                Load        = exerciseSet.Load
            };

            return(set);
        }
        private ExerciseSet CreateExerciseSet(int number, int repetitions, double load)
        {
            var set = new ExerciseSet
            {
                Id          = Guid.NewGuid(),
                Number      = number,
                Repetitions = repetitions,
                Load        = load
            };

            return(set);
        }
Example #14
0
        // DELETE: odata/ExerciseSets(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] Guid key)
        {
            ExerciseSet exerciseSet = await db.ExerciseSets.FindAsync(key);

            if (exerciseSet == null)
            {
                return(NotFound());
            }

            db.ExerciseSets.Remove(exerciseSet);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #15
0
        public List <ExerciseSet> GetExerciseSetsByWorkoutExerciseId(int WorkoutExerciseId)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                using (var command = new SqlCommand("GetExerciseSetsByWorkoutExerciseId", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    List <ExerciseSet> exerciseSets = new List <ExerciseSet>();

                    SqlParameter parameter;
                    parameter = new SqlParameter
                    {
                        ParameterName = "@WorkoutExerciseId",
                        SqlDbType     = SqlDbType.Int,
                        Direction     = ParameterDirection.Input,
                        SqlValue      = WorkoutExerciseId
                    };
                    command.Parameters.Add(parameter);

                    command.Connection.Open();

                    using (var dataReader = command.ExecuteReader())
                    {
                        if (dataReader.HasRows)
                        {
                            while (dataReader.Read())
                            {
                                ExerciseSet exerciseSet = new ExerciseSet
                                {
                                    SetNumber         = dataReader.GetInt32("SetNumber"),
                                    WorkoutExerciseId = dataReader.GetInt32("WorkoutExerciseId"),
                                    Weight            = dataReader.GetDouble("Weight"),
                                    Reps      = dataReader.IsDBNull("Reps") ? null : (int?)dataReader.GetInt32("Reps"),
                                    Time      = dataReader.IsDBNull("Time") ? null : (TimeSpan?)new TimeSpan(0, 0, dataReader.GetInt32("Time")),
                                    Distance  = dataReader.IsDBNull("Distance") ? null : dataReader.GetString("Distance"),
                                    Interval  = dataReader.IsDBNull("Interval") ? null : dataReader.GetString("Interval"),
                                    Skipped   = dataReader.GetBoolean("Skipped"),
                                    Completed = dataReader.GetBoolean("Completed")
                                };
                                exerciseSets.Add(exerciseSet);
                            }
                        }
                    }

                    return(exerciseSets);
                }
            }
        }
 protected virtual ExerciseSet GenerateExerciseSet(ExerciseSet exerciseSet, float weight)
 {
     return(new ExerciseSet
     {
         Id = Guid.NewGuid(),
         Completed = false,
         Distance = exerciseSet.Distance,
         Duration = exerciseSet.Duration,
         NrOfReps = exerciseSet.NrOfReps,
         SetNumber = exerciseSet.SetNumber,
         Weight = weight,
         SetTypeId = exerciseSet.SetTypeId,
         WorkoutRoutineId = NewRoutineId
     });
 }
Example #17
0
 public DAL.App.DTO.ExerciseSet MapBLLToDAL(ExerciseSet bllObject)
 {
     return(new DAL.App.DTO.ExerciseSet
     {
         Id = bllObject.Id,
         ExerciseInTrainingDayId = bllObject.ExerciseInTrainingDayId,
         WorkoutRoutineId = bllObject.WorkoutRoutineId,
         Completed = bllObject.Completed,
         Distance = bllObject.Distance,
         Duration = bllObject.Duration,
         NrOfReps = bllObject.NrOfReps,
         SetNumber = bllObject.SetNumber,
         SetTypeId = bllObject.SetTypeId,
         Weight = bllObject.Weight
     });
 }
Example #18
0
        public void Handle(AddExerciseSetCommand command)
        {
            var exercise = _exerciseRepository.GetExerciseById(command.ExerciseId);
            var user     = _userRepository.GetUserById(command.UserId);

            try
            {
                var exerciseSet = new ExerciseSet(
                    user,
                    exercise,
                    command.Repeats,
                    command.SetsAmount,
                    command.Load,
                    command.Timestamp
                    );
                _exerciseSetRepository.AddExerciseSet(exerciseSet);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
                //TODO throw own Exception
            }
        }
Example #19
0
        // PUT: odata/ExerciseSets(5)
        public async Task <IHttpActionResult> Put([FromODataUri] Guid key, Delta <ExerciseSet> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ExerciseSet exerciseSet = await db.ExerciseSets.FindAsync(key);

            if (exerciseSet == null)
            {
                return(NotFound());
            }

            patch.Put(exerciseSet);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExerciseSetExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(exerciseSet));
        }
 public void AddExerciseSet(ExerciseSet exerciseSet)
 {
     _context.ExerciseSets.Add(exerciseSet);
     _context.SaveChanges();
 }
        //public IList<ExerciseSet> GetExerciseSetsByUser(Guid userId)
        //{
        //    return _context.ExerciseSets.Where(e => e.User.Id == userId.ToString()).ToList();
        //}

        public void UpdateExerciseSet(ExerciseSet exerciseSet)
        {
            _context.ExerciseSets.Update(exerciseSet);
            _context.SaveChanges();
        }