Ejemplo n.º 1
0
        public void CanCreateNewExerciseType()
        {
            using (var repository = new ExerciseTypeRepository())
            {
                var allBeforeItems = repository.FindAll();
                var beforeCount = allBeforeItems.Count();

                var exerciseType = new ExerciseType
                {
                    Created = DateTime.Now,
                    CreatedBy = null,
                    ExerciseName = "CanCreateNewExerciseType",
                    MetricType = Domain.Entities.MetricType.WEIGHT,
                    Modified = DateTime.Now
                };

                repository.Create(exerciseType);
                repository.Save();

                var allAfterItems = repository.FindAll();
                var afterCount = allAfterItems.Count();
                Assert.IsTrue(beforeCount == (afterCount - 1));

                var item = allAfterItems.Last();
                repository.Delete(item);
                repository.Save();

                allAfterItems = repository.FindAll();
                afterCount = allAfterItems.Count();
                Assert.IsTrue(beforeCount == (afterCount));
            }
        }
Ejemplo n.º 2
0
        public void AddNewExercise(ExerciseType exercise)
        {
            if (exercise == null || string.IsNullOrEmpty(exercise.ExerciseName) || exercise.MetricType == Domain.Entities.MetricType.ERROR)
            {
                throw new InvalidExerciseType();
            }

            using (var repo = new ExerciseTypeRepository(_dbKey))
            {
                var matcingExercises = repo.Find(dbExc =>
                                                 dbExc.ExerciseName.Equals(exercise.ExerciseName.Trim(), StringComparison.OrdinalIgnoreCase)
                                                 &&
                                                 dbExc.MetricType == exercise.MetricType
                                                 );
                if (matcingExercises != null && matcingExercises.Count() > 0)
                {
                    throw new ExerciseTypeAlreadyExists();
                }

                exercise.Created   = DateTime.Now;
                exercise.Modified  = DateTime.Now;
                exercise.CreatedBy = null; // todo

                repo.Create(exercise);
                repo.Save();
            }
        }
Ejemplo n.º 3
0
        public void CanCreateNewExerciseType()
        {
            using (var repository = new ExerciseTypeRepository())
            {
                var allBeforeItems = repository.FindAll();
                var beforeCount    = allBeforeItems.Count();

                var exerciseType = new ExerciseType
                {
                    Created      = DateTime.Now,
                    CreatedBy    = null,
                    ExerciseName = "CanCreateNewExerciseType",
                    MetricType   = Domain.Entities.MetricType.WEIGHT,
                    Modified     = DateTime.Now
                };

                repository.Create(exerciseType);
                repository.Save();

                var allAfterItems = repository.FindAll();
                var afterCount    = allAfterItems.Count();
                Assert.IsTrue(beforeCount == (afterCount - 1));

                var item = allAfterItems.Last();
                repository.Delete(item);
                repository.Save();

                allAfterItems = repository.FindAll();
                afterCount    = allAfterItems.Count();
                Assert.IsTrue(beforeCount == (afterCount));
            }
        }
Ejemplo n.º 4
0
 public IEnumerable <ExerciseType> GetAll()
 {
     using (var repo = new ExerciseTypeRepository(_dbKey))
     {
         return(repo.FindAll().ToList());
     }
 }
Ejemplo n.º 5
0
 public IEnumerable<ExerciseType> GetAll()
 {
     using (var repo = new ExerciseTypeRepository(_dbKey))
     {
         return repo.FindAll().ToList();
     }
 }
Ejemplo n.º 6
0
 public bool ExerciseExists(ExerciseType exercise)
 {
     if (exercise == null || string.IsNullOrEmpty(exercise.ExerciseName)) return false;
     using(var repo = new ExerciseTypeRepository(_dbKey))
     {
         var matcingExercises = repo.Find(dbExc =>
             dbExc.ExerciseName.Equals(exercise.ExerciseName.Trim(), StringComparison.OrdinalIgnoreCase)
             &&
             dbExc.MetricType == exercise.MetricType
             );
         if (matcingExercises != null && matcingExercises.Count() > 0)
             return true;
     }
     return false;
 }
Ejemplo n.º 7
0
 public bool ExerciseExists(ExerciseType exercise)
 {
     if (exercise == null || string.IsNullOrEmpty(exercise.ExerciseName))
     {
         return(false);
     }
     using (var repo = new ExerciseTypeRepository(_dbKey))
     {
         var matcingExercises = repo.Find(dbExc =>
                                          dbExc.ExerciseName.Equals(exercise.ExerciseName.Trim(), StringComparison.OrdinalIgnoreCase)
                                          &&
                                          dbExc.MetricType == exercise.MetricType
                                          );
         if (matcingExercises != null && matcingExercises.Count() > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
        public void AddNewExercise(ExerciseType exercise)
        {
            if (exercise == null || string.IsNullOrEmpty(exercise.ExerciseName) || exercise.MetricType == Domain.Entities.MetricType.ERROR)
                throw new InvalidExerciseType();

            using (var repo = new ExerciseTypeRepository(_dbKey))
            {
                var matcingExercises = repo.Find(dbExc =>
                    dbExc.ExerciseName.Equals(exercise.ExerciseName.Trim(), StringComparison.OrdinalIgnoreCase)
                    &&
                    dbExc.MetricType == exercise.MetricType
                    );
                if (matcingExercises != null && matcingExercises.Count() > 0)
                    throw new ExerciseTypeAlreadyExists();

                exercise.Created = DateTime.Now;
                exercise.Modified = DateTime.Now;
                exercise.CreatedBy = null; // todo

                repo.Create(exercise);
                repo.Save();
            }
        }