public static ApiExercise DataToApiModel(Exercise exercise)
 {
     return new ApiExercise()
     {
         Id = exercise.Id,
         Title = exercise.Title
     };
 }
Пример #2
0
        public CreateResponse CreateExercise(Exercise exercise)
        {
            CreateResponse cr = new CreateResponse();

            Common.Collections coll = new Collections();
            cr = coll.CreateExercise(exercise);

            return cr;
        }
Пример #3
0
        public Exercise CreateExerciseCollection(Exercise exercise)
        {
            var exerciseResponse = new Exercise();

            if (exercise.CreatePassword == CreatePassword)
            {

                MongoServer mongo = MongoServer.Create(DbConnectionString);
                try
                {
                    MongoDatabase database = null;

                    if (DbLocation.Equals("Local"))
                    {
                        database = mongo.GetDatabase("workout");
                    }
                    else
                    {
                        //below is for mongolab
                        MongoCredentials mc = new MongoCredentials(DbLogin, DbPassword);
                        database = mongo.GetDatabase(DbName, mc);
                        //end of monglab
                    }

                    MongoCollection<ExerciseInternal> exercises = database.GetCollection<ExerciseInternal>("exercise");
                    var exerciseInternal = new ExerciseInternal();
                    exerciseInternal = Maps.Map(exercise);
                    //var result = exercises.Insert(exerciseInternal);
                }
                catch (Exception ex)
                {
                    //TODO:  Add some logging...
                }
                finally
                {
                    mongo.Disconnect();
                }
            }

            return exercise;
        }
        private void CreateTestLogAndExercise(out Log log, out Exercise exercise)
        {
            var person = CreateTestPerson("andycornforth");
            _personRepository.AddPerson(person);
            person = _personRepository.GetPersonByUsername("andycornforth");

            log = new Log()
            {
                PersonId = person.Id,
                Title = "Test Log"
            };
            _logRepository.AddLog(log);
            log = _logRepository.GetAllLogsByUserId(person.Id).FirstOrDefault();

            _exerciseRepository.AddExercise("Squat");
            exercise = _exerciseRepository.GetAllExercises().FirstOrDefault();
        }
Пример #5
0
        public UpdateResponse UpdateExercise(Exercise exercise)
        {
            var cr = new UpdateResponse();

            return cr;
        }