internal static ExerciseInternal Map(Exercise exerciseIn) { ExerciseInternal exOut = new ExerciseInternal(); exOut = Mapper.Map <Exercise, ExerciseInternal>(exerciseIn); exOut.set = exerciseIn.setNumber; return(exOut); }
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); }
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); }
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; }