Exemple #1
0
    public void FinishWorkout(bool isFreeMode = false)
    {
        var cws = GameManager.instance.currentWorkoutSession;

        GameManager.instance.isCurrentWorkoutActive = false;
        countdownLabel.text = "<size=50>Workout " + (workoutCounter + 1) + " / " + GameManager.instance.todaysChallenge.challenges.Count + " beendet!</size>";

        cws.durationCompleted = cws.durationSetup - durationInSec;

        cws.CalculateCalories();
        //clone workoutSession
        WorkoutSession ws = new WorkoutSession();

        ws.workoutId         = cws.workoutId;
        ws.kcal              = cws.kcal;
        ws.durationSetup     = cws.durationSetup;
        ws.durationCompleted = cws.durationCompleted;
        ws.isFreeMode        = cws.isFreeMode;
        GameManager.instance.AddWorkoutSessionToHistory(ws);
        cws.Clear();
        hasAddedWorkoutSessionToHistory = true;
        // add 1 XP per 1 Minute of completed workout
        GameManager.instance.AddXP((int)(ws.durationCompleted / 60));


        workoutCounter++;
        if (workoutCounter < GameManager.instance.todaysChallenge.challenges.Count)
        {
            StartCoroutine(WorkoutCooldown(5f));
        }
        else
        {
            StartCoroutine(DailyChallengeComplete(2f));
        }
    }
    public void FinishWorkout(bool isFreeMode = false)
    {
        var cws = GameManager.instance.currentWorkoutSession;

        GameManager.instance.isCurrentWorkoutActive = false;
        countdownLabel.text = "<size=50>Workout beendet!</size>";
        if (!isFreeMode)
        {
            cws.durationCompleted = cws.durationSetup - durationInSec;
        }
        else
        {
            cws.durationCompleted = durationInSec;
        }

        cws.CalculateCalories();
        //clone workoutSession
        WorkoutSession ws = new WorkoutSession();

        ws.workoutId         = cws.workoutId;
        ws.kcal              = cws.kcal;
        ws.durationSetup     = cws.durationSetup;
        ws.durationCompleted = cws.durationCompleted;
        ws.isFreeMode        = cws.isFreeMode;
        GameManager.instance.AddWorkoutSessionToHistory(ws);
        cws.Clear();
        hasAddedWorkoutSessionToHistory = true;
        // add 1 XP per 1 Minute of completed workout
        GameManager.instance.AddXP((int)(ws.durationCompleted / 60));
    }
        public async Task <IActionResult> Post(
            [FromBody] WorkoutSessionUpdateApi workoutSessionUpdate)
        {
            var workoutSession = new WorkoutSession
            {
                Id   = Guid.NewGuid(),
                Note = workoutSessionUpdate.Note,
                StartEpochTimestamp = workoutSessionUpdate.StartDatetime.ToEpoch()
            };

            var userResult = await CheckUser();

            if (userResult.NotExist)
            {
                return(BadRequest("No User Found."));
            }

            var ws = await _workoutSessionRepository.Add(workoutSession, userResult.User.Id);

            return(CreatedAtRoute("GetWorkoutSession",
                                  new { Controller = "WorkoutSession", id = ws.Id },
                                  new WorkoutSessionApi
            {
                Id = ws.Id,
                Note = ws.Note,
                StartDatetime = ws.StartDatetime,
                EndDatetime = ws.EndDatetime
            }));
        }
        // POST: odata/WorkoutSessions
        public async Task <IHttpActionResult> Post(WorkoutSession workoutSession)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.WorkoutSessions.Add(workoutSession);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (WorkoutSessionExists(workoutSession.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(workoutSession));
        }
Exemple #5
0
        public JsonResult Update([FromBody] WorkoutSession workoutSession)
        {
            var context = new WorkoutTrackerContext();

            workoutSession.UserId = this.UserId;
            context.Entry(context.WorkoutSessions.Find(workoutSession.Id)).CurrentValues.SetValues(workoutSession);
            context.SaveChanges();
            return(Json(workoutSession));
        }
Exemple #6
0
        public JsonResult Create([FromBody] WorkoutSession workoutSession)
        {
            var context = new WorkoutTrackerContext();

            workoutSession.UserId = this.UserId;
            context.WorkoutSessions.Add(workoutSession);
            context.SaveChanges();
            return(Json(workoutSession));
        }
        public int Update(WorkoutSession entity)
        {
            WorkoutSession fromDatabase = Get(entity.Id);

            DatabaseContext.Entry(fromDatabase).CurrentValues.SetValues(entity);
            DatabaseContext.Entry(fromDatabase).State = EntityState.Modified;

            return(DatabaseContext.SaveChanges());
        }
 public WorkoutSession UpdateWorkoutSession(WorkoutSession workoutSession)
 {
     using (var db = new WorkoutDb())
     {
         workoutSession.Ended = DateTime.Now;
         db.Update(workoutSession);
         db.SaveChanges();
         return(workoutSession);
     }
 }
        public void WorkoutSessionTestWorkoutSessionWithNullWorkout_Validate_Invalid()
        {
            //Arrange
            _entity = new WorkoutSession {
                Name = "Name", Workout = null
            };

            //Act
            var errorsList = new List <ValidationResult>(_entity.Validate(new ValidationContext(this)));

            //Assert
            Assert.IsTrue(errorsList.Count == 1);
        }
 public void AddWorkoutSessionToHistory(WorkoutSession ws)
 {
     if (workoutHistory.ContainsKey(DateTime.Now.Date))
     {
         workoutHistory[DateTime.Now.Date].Add(ws);
     }
     else
     {
         List <WorkoutSession> lws = new List <WorkoutSession>();
         lws.Add(ws);
         workoutHistory.Add(DateTime.Now.Date, lws);
     }
 }
        public int Update(Workout entity)
        {
            Workout fromDatabase = Get(entity.Id);

            DatabaseContext.Entry(fromDatabase).CurrentValues.SetValues(entity);
            DatabaseContext.Entry(fromDatabase).State = EntityState.Modified;

            if (entity.Sessions != null && entity.Sessions.Any())
            {
                foreach (WorkoutSession workoutSession in entity.Sessions)
                {
                    workoutSession.Workout = fromDatabase;

                    if (workoutSession.Id == 0)
                    {
                        DatabaseContext.SetOwnable <WorkoutSession>().Add(workoutSession);
                    }
                    else
                    {
                        if (DatabaseContext.SetOwnable <WorkoutSession>().Local.All(e => e.Id != workoutSession.Id))
                        {
                            DatabaseContext.SetOwnable <WorkoutSession>().Attach(workoutSession);
                        }
                        WorkoutSession fromDatabaseWorkoutSession =
                            DatabaseContext.SetOwnable <WorkoutSession>().Single(x => x.Id == workoutSession.Id);
                        DatabaseContext.Entry(fromDatabaseWorkoutSession).CurrentValues.SetValues(workoutSession);
                        DatabaseContext.Entry(fromDatabaseWorkoutSession).State = EntityState.Modified;
                    }
                }
            }

            /*else
             * {
             *  fromDatabase.Sessions = null;
             *  IQueryable<WorkoutSession> workoutSessionsToRemove = DatabaseContext.SetOwnable<WorkoutSession>().Where(x => x.Workout.Id == entity.Id);
             *  foreach (var workoutSessionToRemove in workoutSessionsToRemove)
             *  {
             *      DatabaseContext.SetOwnable<WorkoutSession>().Remove(workoutSessionToRemove);
             *  }
             * }
             *
             * if (fromDatabase.Sessions != null)
             * {
             *  foreach (var workoutSessionToRemove in fromDatabase.Sessions.Where(x => entity.Sessions.All(u => u.Id != x.Id)).ToList())
             *  {
             *      DatabaseContext.SetOwnable<WorkoutSession>().Remove(workoutSessionToRemove);
             *  }
             * }*/

            return(DatabaseContext.SaveChanges());
        }
        // DELETE: odata/WorkoutSessions(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] Guid key)
        {
            WorkoutSession workoutSession = await db.WorkoutSessions.FindAsync(key);

            if (workoutSession == null)
            {
                return(NotFound());
            }

            db.WorkoutSessions.Remove(workoutSession);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IActionResult Save(WorkoutSession workoutSession)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            workoutSession.TimeDateForWorkout = DateTime.Now;

            _db.WorkoutSession.Add(workoutSession);
            _db.SaveChanges();

            return(View());
        }
Exemple #14
0
        public void WorkoutSessionMapping_ModelToViewModelDefaultValue_Valid()
        {
            //Arrange
            _model = new WorkoutSession();

            //Act
            _viewModel = _mapper.GetViewModel(_model);

            //Assert
            Assert.AreEqual(_model.Id, _viewModel.Id);
            Assert.AreEqual(_model.Name, _viewModel.Name);
            Assert.AreEqual(default(int), _viewModel.WorkoutId);
            Assert.AreEqual(default(int), _viewModel.Exercises.Count());
        }
        public async Task <WorkoutSession> AddWorkoutSession(CreateWorkoutSessionCommand command)
        {
            var workoutSession = new WorkoutSession
            {
                Description    = command.Description,
                Date           = command.Date,
                WorkoutRecords = command.WorkoutRecords,
                UserId         = 1 // TODO : Change to proper userId
            };

            _context.WorkoutSessions.Add(workoutSession);
            await _context.SaveChangesAsync();

            return(workoutSession);
        }
        public async Task <IActionResult> Session(long PlanID, int SessionIndex)
        {
            FitnessUser currentUser = await GetUser();

            WorkoutPlan plan = await dbContext.WorkoutPlans.FirstOrDefaultAsync(plan => plan.ID == PlanID && plan.User == currentUser);

            if (plan == null || SessionIndex < 0 || SessionIndex >= plan.Sessions.Length)
            {
                return(BadRequest());
            }

            WorkoutSession session = plan.Sessions[SessionIndex];

            return(View(session));
        }
Exemple #17
0
        private async Task <WorkoutSession> GetWorkoutSession(IStatementResultCursor reader)
        {
            WorkoutSession item = null;

            while (await reader.FetchAsync())
            {
                item = new WorkoutSession()
                {
                    Id   = Guid.Parse(reader.Current[0].ToString()),
                    Note = reader.Current[1]?.ToString(),
                    StartEpochTimestamp = double.Parse(reader.Current[2].ToString()),
                    EndEpochTimestamp   = (reader.Current[3] != null) ?
                                          double.Parse(reader.Current[3].ToString()) : 0
                };
            }
            return(item);
        }
        public WorkoutSession CreateWorkoutSession(int dayId, Guid userId)
        {
            using (var db = new WorkoutDb())
            {
                var session = new WorkoutSession
                {
                    DayId       = dayId,
                    UserId      = userId,
                    IsCompleted = false
                };

                db.WorkoutSessions.Add(session);
                db.SaveChanges();

                return(session);
            }
        }
        public int Insert(WorkoutSession entity)
        {
            if (entity.Workout != null)
            {
                if (DatabaseContext.SetOwnable <Workout>().Local.All(e => e.Id != entity.Workout.Id))
                {
                    DatabaseContext.SetOwnable <Workout>().Attach(entity.Workout);
                }
            }

            if (entity.WorkoutSessionExercises != null && !entity.WorkoutSessionExercises.Any())
            {
                entity.WorkoutSessionExercises = null;
            }

            DatabaseContext.SetOwnable <WorkoutSession>().Add(entity);
            return(DatabaseContext.SaveChanges());
        }
        public void WorkoutSessionTestWorkoutSessionWithExerciceWithDiffOrder_Validate_Valid()
        {
            //Arrange
            _entity = new WorkoutSession {
                Name = "Name", Workout = new Workout(), WorkoutSessionExercises = new List <WorkoutSessionExercise> {
                    new WorkoutSessionExercise {
                        Order = 1
                    }, new WorkoutSessionExercise {
                        Order = 2
                    }
                }
            };

            //Act
            var errorsList = new List <ValidationResult>(_entity.Validate(new ValidationContext(this)));

            //Assert
            Assert.IsTrue(errorsList.Count == 0);
        }
        public async Task <IActionResult> Update(
            Guid id, [FromBody] WorkoutSessionUpdateApi workoutSessionUpdate)
        {
            if (await _workoutSessionRepository.Get(id) == null)
            {
                return(NotFound());
            }

            var workoutSession = new WorkoutSession
            {
                Id   = id,
                Note = workoutSessionUpdate.Note,
                StartEpochTimestamp = workoutSessionUpdate.StartDatetime.ToEpoch(),
                EndEpochTimestamp   = workoutSessionUpdate.EndDatetime.ToEpoch()
            };

            await _workoutSessionRepository.Update(workoutSession);

            return(NoContent());
        }
Exemple #22
0
        public async Task <WorkoutSession> GetSessionForDay(int?userId, DateTime date)
        {
            var session = await _context.WorkoutSessions
                          .Include(w => w.ConcreteExercises)
                          .ThenInclude(c => c.Attributes)
                          .SingleOrDefaultAsync(w => w.WTUserID == userId && w.Date.Value.Date == date.Date);

            if (session == null)
            {
                session = new WorkoutSession
                {
                    Date     = date,
                    WTUserID = userId
                };
                _context.WorkoutSessions.Add(session);
                await _context.SaveChangesAsync();
            }

            return(session);
        }
Exemple #23
0
        public async Task <WorkoutSession> Update(WorkoutSession workoutSession)
        {
            using (var session = _graphRepository.Driver.Session())
            {
                var reader = await session.RunAsync(
                    @"MATCH (ws:WorkoutSession { id: $id }) 
                    SET ws.note = $note, ws.startEpochTimestamp = $startEpochTimestamp, ws.endEpochTimestamp = $endEpochTimestamp
                    RETURN ws.id, ws.note, ws.startEpochTimestamp, ws.endEpochTimestamp",
                    new
                {
                    id   = workoutSession.Id.ToString(),
                    note = workoutSession.Note,
                    startEpochTimestamp = workoutSession.StartEpochTimestamp,
                    endEpochTimestamp   = workoutSession.EndEpochTimestamp
                }
                    );

                workoutSession = await GetWorkoutSession(reader);
            }
            return(workoutSession);
        }
Exemple #24
0
        public async Task <WorkoutSession> AddOrUpdateSession(int?userId, DateTime date, List <WorkoutRoutine> routines, List <Exercise> exercises, List <ConcreteExercise> concreteExercises)
        {
            WorkoutSession session = null;

            if (routines != null && routines.Count > 0)
            {
                session = await AddRoutineToSession(userId, date, routines);
            }

            if (exercises != null && exercises.Count > 0)
            {
                session = await AddExercisesToSession(userId, date, exercises);
            }

            if (concreteExercises != null && concreteExercises.Count > 0)
            {
                session = await UpdateConcreteExercises(userId, date, concreteExercises);
            }

            return(session);
        }
Exemple #25
0
        public async Task <WorkoutSession> Add(WorkoutSession workoutSession, Guid userId)
        {
            using (var session = _graphRepository.Driver.Session())
            {
                var reader = await session.RunAsync(
                    @"MATCH (u:User { id: $userId })
                    CREATE (ws:WorkoutSession { id: $id, note: $note, startEpochTimestamp: $startEpochTimestamp, endEpochTimestamp: 0 }),
                    (ws)-[:BY_USER]->(u)
                    RETURN ws.id, ws.note, ws.startEpochTimestamp, ws.endEpochTimestamp",
                    new
                {
                    userId = userId,
                    id     = workoutSession.Id.ToString(),
                    note   = workoutSession.Note,
                    startEpochTimestamp = workoutSession.StartEpochTimestamp
                }
                    );

                workoutSession = await GetWorkoutSession(reader);
            }
            return(workoutSession);
        }
Exemple #26
0
        public void WorkoutSessionMapping_ModelToViewModelAllFieldsWithValues_Valid()
        {
            //Arrange
            _model      = new WorkoutSession();
            _model.Id   = 1;
            _model.Name = "Test Workout Session";
            _model.WorkoutSessionExercises = new WorkoutSessionExercise[2] {
                new WorkoutSessionExercise(), new WorkoutSessionExercise()
            };
            _model.Workout = new Workout {
                Id = 1
            };

            //Act
            _viewModel = _mapper.GetViewModel(_model);

            //Assert
            Assert.AreEqual(_model.Id, _viewModel.Id);
            Assert.AreEqual(_model.Name, _viewModel.Name);
            Assert.AreEqual(1, _viewModel.WorkoutId);
            Assert.AreEqual(_model.WorkoutSessionExercises.Count(), _viewModel.Exercises.Count());
        }
Exemple #27
0
        public ActionResult EditWithSessionEdit(WorkoutViewModel viewModel)
        {
            dynamic json = JsonConvert.DeserializeObject(viewModel.SessionsString);

            Model.Sessions = new Collection <WorkoutSession>();
            foreach (var session in json.sessions)
            {
                var workoutSession = new WorkoutSession {
                    Id = session.id
                };
                Model.Sessions.Add(workoutSession);
                workoutSession.WorkoutSessionExercises = new Collection <WorkoutSessionExercise>();
                foreach (var exercise in session.exercises)
                {
                    var workoutSessionExercise = new WorkoutSessionExercise {
                        Exercise = new Exercise {
                            Id = exercise.idexercise
                        }
                    };
                    if (exercise.idsessionexercise != "")
                    {
                        workoutSessionExercise.Id = exercise.idsessionexercise;
                    }
                    workoutSession.WorkoutSessionExercises.Add(workoutSessionExercise);
                }
            }
            int numberUpdated = ServiceFactory.Workout.Update(Model);

            var viewModelReturn = BuildWorkoutWithAllExercises(Model.Id);

            if (numberUpdated > 0)
            {
                viewModelReturn.SavedMessage = "Workout Saved Successfully";
            }
            return(View("EditWithSessionEdit", viewModelReturn));
        }
        // PUT: odata/WorkoutSessions(5)
        public async Task <IHttpActionResult> Put([FromODataUri] Guid key, Delta <WorkoutSession> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            WorkoutSession workoutSession = await db.WorkoutSessions.FindAsync(key);

            if (workoutSession == null)
            {
                return(NotFound());
            }

            patch.Put(workoutSession);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkoutSessionExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(workoutSession));
        }
 public WorkoutSession Put([FromBody] WorkoutSession workoutSession)
 {
     return(_recordWorkoutService.UpdateWorkoutSession(workoutSession));
 }
Exemple #30
0
        public static void Initialize(WorkoutTrackingDBContext context)
        {
            context.Database.EnsureCreated();

            if (context.Users.Any())
            {
                return;   // DB has been seeded
            }

            var users = new WTUser[]
            {
                new WTUser {
                    FirstName = "Riste", LastName = "Poposki", RegisterDate = DateTime.Parse("2017-09-01"), Email = "*****@*****.**", Password = "******", Username = "******"
                },
                new WTUser {
                    FirstName = "Monkas", LastName = "MonkaGiga", RegisterDate = DateTime.Now, Email = "*****@*****.**", Password = "******", Username = "******"
                },
            };

            context.Users.AddRange(users);
            context.SaveChanges();


            var exercises = new Exercise[]
            {
                new Exercise {
                    Name = "Riste Execise 1", WTUserID = 1, Category = Category.ARMS, Description = "Riste Execise Desc 1", IsEditable = true, ImagePath = "Images/monkas.jpg"
                },
                new Exercise {
                    Name = "Riste Execise 2", WTUserID = 1, Category = Category.CHEST, Description = "Riste Execise Desc 2", IsEditable = true, ImagePath = "Images/monkas.jpg"
                },
                new Exercise {
                    Name = "Monkas Execise 1", WTUserID = 2, Category = Category.LEGS, Description = "Monkas Execise Desc 1", IsEditable = true, ImagePath = "Images/monkas.jpg"
                },
                new Exercise {
                    Name = "Monkas Execise 2", WTUserID = 2, Category = Category.OTHER, Description = "Monkas Execise Desc 2", IsEditable = true, ImagePath = "Images/monkas.jpg"
                }
            };

            context.Exercises.AddRange(exercises);
            context.SaveChanges();


            var routines = new WorkoutRoutine[]
            {
                new WorkoutRoutine {
                    Name = "Riste Workout 1", Description = "Riste Routine Desc 1", WTUserID = 1, ImagePath = "Images/monkasRoutine.jpg"
                },
                new WorkoutRoutine {
                    Name = "Riste Workout 2", Description = "Riste Routine Desc 2", WTUserID = 1, ImagePath = "Images/monkasRoutine.jpg"
                },
                new WorkoutRoutine {
                    Name = "Monkas Workout 1", Description = "Monkas Routine Desc 1", WTUserID = 2, ImagePath = "Images/monkasRoutine.jpg"
                },
                new WorkoutRoutine {
                    Name = "Monkas Workout 1", Description = "Monkas Routine Desc 2", WTUserID = 2, ImagePath = "Images/monkasRoutine.jpg"
                }
            };

            context.WorkoutRoutines.AddRange(routines);
            context.SaveChanges();


            var programs = new WorkoutProgram[]
            {
                new WorkoutProgram {
                    Name = "Riste Program 1", Description = "Riste Program Desc 1", WTUserID = 1, ImagePath = "Images/monkasProgram.png"
                },
                new WorkoutProgram {
                    Name = "Riste Program 2", Description = "Riste Program Desc 2", WTUserID = 1, ImagePath = "Images/monkasProgram.png"
                },
                new WorkoutProgram {
                    Name = "Monkas Program 1", Description = "Monkas Program Desc 1", WTUserID = 2, ImagePath = "Images/monkasProgram.png"
                },
                new WorkoutProgram {
                    Name = "Monkas Program 1", Description = "Monkas Program Desc 2", WTUserID = 2, ImagePath = "Images/monkasProgram.png"
                },
            };

            context.WorkoutPrograms.AddRange(programs);
            context.SaveChanges();


            var sessions = new WorkoutSession[]
            {
                new WorkoutSession {
                    Date = DateTime.Now, WTUserID = 1
                },
                new WorkoutSession {
                    Date = DateTime.Now.AddDays(1), WTUserID = 1
                },
                new WorkoutSession {
                    Date = DateTime.Now, WTUserID = 2
                },
                new WorkoutSession {
                    Date = DateTime.Now.AddDays(1), WTUserID = 2
                },
            };

            context.WorkoutSessions.AddRange(sessions);
            context.SaveChanges();


            var bodyStats = new BodyStatistic[]
            {
                new BodyStatistic {
                    DateCreated = DateTime.Now, Year = DateTime.Now.Year, Month = DateTime.Now.Month, Week = DateTime.Now.GetWeekOfMonth(), WTUserID = 1
                },
                new BodyStatistic {
                    DateCreated = DateTime.Now.AddDays(7), Year = DateTime.Now.AddDays(7).Year,
                    Month       = DateTime.Now.AddDays(7).Month, Week = DateTime.Now.AddDays(7).GetWeekOfMonth(), WTUserID = 1
                },

                new BodyStatistic {
                    DateCreated = DateTime.Now, Year = DateTime.Now.Year, Month = DateTime.Now.Month, Week = DateTime.Now.GetWeekOfMonth(), WTUserID = 2
                },
                new BodyStatistic {
                    DateCreated = DateTime.Now.AddDays(7), Year = DateTime.Now.AddDays(7).Year,
                    Month       = DateTime.Now.AddDays(7).Month, Week = DateTime.Now.AddDays(7).GetWeekOfMonth(), WTUserID = 2
                },
            };

            context.BodyStatistics.AddRange(bodyStats);
            context.SaveChanges();



            var bodyAttributeTemplate = new BodyAttributeTemplate[]
            {
                new BodyAttributeTemplate {
                    AttributeName = "Template Attr 1", AttributeValue = "OK1", WTUserID = 1, IsDeletable = true
                },
                new BodyAttributeTemplate {
                    AttributeName = "Template Attr 2", AttributeValue = "OK2", WTUserID = 1, IsDeletable = true
                },
                new BodyAttributeTemplate {
                    AttributeName = "Template Attr 3", AttributeValue = "NO1", WTUserID = 2, IsDeletable = true
                },
                new BodyAttributeTemplate {
                    AttributeName = "Template Attr 4", AttributeValue = "NO2", WTUserID = 2, IsDeletable = true
                }
            };

            context.BodyAttributeTemplates.AddRange(bodyAttributeTemplate);
            context.SaveChanges();



            var exerciseAttribute1 = new ExerciseAttribute {
                AttributeName = "Sets", AttributeValue = "value1", ExerciseID = 1, IsDeletable = false
            };
            var exerciseAttribute2 = new ExerciseAttribute {
                AttributeName = "Repetitions", AttributeValue = "value2", ExerciseID = 2, IsDeletable = false
            };
            var exerciseAttribute3 = new ExerciseAttribute {
                AttributeName = "Sets", AttributeValue = "value1", ExerciseID = 3, IsDeletable = false
            };
            var exerciseAttribute4 = new ExerciseAttribute {
                AttributeName = "Repetitions", AttributeValue = "value2", ExerciseID = 4, IsDeletable = false
            };

            var exercise = context.Exercises.SingleOrDefault(e => e.ID == 1);

            exercise.Attributes = new List <ExerciseAttribute>();
            exercise.Attributes.Add(exerciseAttribute1);

            exercise            = context.Exercises.SingleOrDefault(e => e.ID == 2);
            exercise.Attributes = new List <ExerciseAttribute>();
            exercise.Attributes.Add(exerciseAttribute2);

            exercise            = context.Exercises.SingleOrDefault(e => e.ID == 3);
            exercise.Attributes = new List <ExerciseAttribute>();
            exercise.Attributes.Add(exerciseAttribute3);

            exercise            = context.Exercises.SingleOrDefault(e => e.ID == 4);
            exercise.Attributes = new List <ExerciseAttribute>();
            exercise.Attributes.Add(exerciseAttribute4);
            context.SaveChanges();



            var bodyStatAttribute1 = new BodyStatAttribute {
                AttributeName = "Riste Height", AttributeValue = "173", BodyStatisticID = 1, IsDeletable = true
            };
            var bodyStatAttribute2 = new BodyStatAttribute {
                AttributeName = "Riste Weight", AttributeValue = "71", BodyStatisticID = 2, IsDeletable = true
            };
            var bodyStatAttribute3 = new BodyStatAttribute {
                AttributeName = "Monkas Height", AttributeValue = "195", BodyStatisticID = 3, IsDeletable = true
            };
            var bodyStatAttribute4 = new BodyStatAttribute {
                AttributeName = "Monkas Weight", AttributeValue = "91", BodyStatisticID = 4, IsDeletable = true
            };

            var bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 1);

            bodyStat.BodyStatAttributes = new List <BodyStatAttribute>();
            bodyStat.BodyStatAttributes.Add(bodyStatAttribute1);

            bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 2);
            bodyStat.BodyStatAttributes = new List <BodyStatAttribute>();
            bodyStat.BodyStatAttributes.Add(bodyStatAttribute2);

            bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 3);
            bodyStat.BodyStatAttributes = new List <BodyStatAttribute>();
            bodyStat.BodyStatAttributes.Add(bodyStatAttribute3);

            bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 4);
            bodyStat.BodyStatAttributes = new List <BodyStatAttribute>();
            bodyStat.BodyStatAttributes.Add(bodyStatAttribute4);
            context.SaveChanges();



            var progressImage1 = new ProgressImage {
                DateCreated = DateTime.Now, Url = "url1", BodyStatisticID = 1
            };
            var progressImage2 = new ProgressImage {
                DateCreated = DateTime.Now.AddDays(1), Url = "url2", BodyStatisticID = 2
            };
            var progressImage3 = new ProgressImage {
                DateCreated = DateTime.Now.AddDays(2), Url = "url3", BodyStatisticID = 3
            };
            var progressImage4 = new ProgressImage {
                DateCreated = DateTime.Now.AddDays(3), Url = "url4", BodyStatisticID = 4
            };

            bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 1);
            bodyStat.ProgressImages = new List <ProgressImage>();
            bodyStat.ProgressImages.Add(progressImage1);

            bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 2);
            bodyStat.ProgressImages = new List <ProgressImage>();
            bodyStat.ProgressImages.Add(progressImage2);

            bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 3);
            bodyStat.ProgressImages = new List <ProgressImage>();
            bodyStat.ProgressImages.Add(progressImage3);

            bodyStat = context.BodyStatistics.SingleOrDefault(e => e.ID == 4);
            bodyStat.ProgressImages = new List <ProgressImage>();
            bodyStat.ProgressImages.Add(progressImage4);
            context.SaveChanges();



            var exerciseRoutineEntry1 = new ExerciseRoutineEntry {
                ExerciseID = 1, WorkoutRoutineID = 1
            };
            var exerciseRoutineEntry2 = new ExerciseRoutineEntry {
                ExerciseID = 2, WorkoutRoutineID = 1
            };
            var exerciseRoutineEntry3 = new ExerciseRoutineEntry {
                ExerciseID = 1, WorkoutRoutineID = 2
            };

            var routine = context.WorkoutRoutines.SingleOrDefault(u => u.ID == 1);

            routine.ExerciseRoutineEntries = new List <ExerciseRoutineEntry>();
            routine.ExerciseRoutineEntries.Add(exerciseRoutineEntry1);
            routine.ExerciseRoutineEntries.Add(exerciseRoutineEntry2);

            routine = context.WorkoutRoutines.SingleOrDefault(u => u.ID == 2);
            routine.ExerciseRoutineEntries = new List <ExerciseRoutineEntry>();
            routine.ExerciseRoutineEntries.Add(exerciseRoutineEntry3);

            var exerciseRoutineEntry4 = new ExerciseRoutineEntry {
                ExerciseID = 3, WorkoutRoutineID = 3
            };
            var exerciseRoutineEntry5 = new ExerciseRoutineEntry {
                ExerciseID = 4, WorkoutRoutineID = 3
            };
            var exerciseRoutineEntry6 = new ExerciseRoutineEntry {
                ExerciseID = 3, WorkoutRoutineID = 4
            };

            routine = context.WorkoutRoutines.SingleOrDefault(u => u.ID == 3);
            routine.ExerciseRoutineEntries = new List <ExerciseRoutineEntry>();
            routine.ExerciseRoutineEntries.Add(exerciseRoutineEntry4);
            routine.ExerciseRoutineEntries.Add(exerciseRoutineEntry5);

            routine = context.WorkoutRoutines.SingleOrDefault(u => u.ID == 4);
            routine.ExerciseRoutineEntries = new List <ExerciseRoutineEntry>();
            routine.ExerciseRoutineEntries.Add(exerciseRoutineEntry6);
            context.SaveChanges();



            var routineProgramEntry1 = new RoutineProgramEntry {
                WorkoutRoutineID = 1, WorkoutProgramID = 1, PlannedDates = "2018-05-26;2018-06-01"
            };
            var routineProgramEntry2 = new RoutineProgramEntry {
                WorkoutRoutineID = 2, WorkoutProgramID = 1, PlannedDates = "2018-05-29"
            };
            var routineProgramEntry3 = new RoutineProgramEntry {
                WorkoutRoutineID = 1, WorkoutProgramID = 2, PlannedDates = "2018-07-26;2018-07-27"
            };

            var program = context.WorkoutPrograms.SingleOrDefault(u => u.ID == 1);

            program.RoutineProgramEntries = new List <RoutineProgramEntry>();
            program.RoutineProgramEntries.Add(routineProgramEntry1);
            program.RoutineProgramEntries.Add(routineProgramEntry2);

            program = context.WorkoutPrograms.SingleOrDefault(u => u.ID == 2);
            program.RoutineProgramEntries = new List <RoutineProgramEntry>();
            program.RoutineProgramEntries.Add(routineProgramEntry3);

            var routineProgramEntry4 = new RoutineProgramEntry {
                WorkoutRoutineID = 3, WorkoutProgramID = 3, PlannedDates = "2018-01-26;2018-01-27"
            };
            var routineProgramEntry5 = new RoutineProgramEntry {
                WorkoutRoutineID = 4, WorkoutProgramID = 3, PlannedDates = "2018-02-26"
            };
            var routineProgramEntry6 = new RoutineProgramEntry {
                WorkoutRoutineID = 3, WorkoutProgramID = 4, PlannedDates = "2018-03-26;2018-03-27"
            };

            program = context.WorkoutPrograms.SingleOrDefault(u => u.ID == 3);
            program.RoutineProgramEntries = new List <RoutineProgramEntry>();
            program.RoutineProgramEntries.Add(routineProgramEntry4);
            program.RoutineProgramEntries.Add(routineProgramEntry5);

            program = context.WorkoutPrograms.SingleOrDefault(u => u.ID == 4);
            program.RoutineProgramEntries = new List <RoutineProgramEntry>();
            program.RoutineProgramEntries.Add(routineProgramEntry6);
            context.SaveChanges();



            var ConcreteExercisesList = exercises.ToList().Select(item => item.GetConcreteExerciseObject()).ToList();

            for (int i = 0; i < ConcreteExercisesList.Count(); i++)
            {
                var item = ConcreteExercisesList[i];
                item.WorkoutSessionID = i + 1;
                context.ConcreteExercises.Add(item);
            }
            context.SaveChanges();
        }