Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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();
            }
        }