コード例 #1
0
        internal static ExerciseInternal Map(Exercise exerciseIn)
        {
            ExerciseInternal exOut = new ExerciseInternal();

            exOut     = Mapper.Map <Exercise, ExerciseInternal>(exerciseIn);
            exOut.set = exerciseIn.setNumber;
            return(exOut);
        }
コード例 #2
0
        internal static Exercise Map(ExerciseInternal exerciseIn)
        {
            Exercise exOut = new Exercise();

            exOut           = Mapper.Map <ExerciseInternal, Exercise>(exerciseIn);
            exOut.setNumber = exerciseIn.set;  //note this is setNumber because set is used in ember.js
            exOut.Id        = exerciseIn.Id.ToString();
            return(exOut);
        }
コード例 #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);
        }
コード例 #4
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;
        }