Exemplo n.º 1
0
 public void RemoveUser()
 {
     using (var db = new GymTrackerContext())
     {
         db.Users.Remove(SelectedUser);
         db.SaveChanges();
         SelectedUser        = null;
         SelectedSession     = null;
         SelectedExercise    = null;
         SelectedMuscleGroup = null;
         SelectedSet         = null;
     }
 }
Exemplo n.º 2
0
 public void AddExercise(string name)
 {
     using (var db = new GymTrackerContext())
     {
         var newExersice = new Exercise()
         {
             ExerciseName  = name,
             MuscleGroupId = SelectedMuscleGroup.MuscleGroupId
         };
         db.Exercises.Add(newExersice);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void AddandSelectUser(string name)
 {
     using (var db = new GymTrackerContext())
     {
         var newUser = new User()
         {
             UserName = name
         };
         db.Users.Add(newUser);
         db.SaveChanges();
         SelectedUser = newUser;
     }
 }
Exemplo n.º 4
0
 public void RemoveSet()
 {
     using (var db = new GymTrackerContext())
     {
         db.Sets.Remove(SelectedSet);
         db.SaveChanges();
         var allinSession = ReadSessionSets();
         foreach (var item in allinSession)
         {
             SelectedSet = item;
             UpdateSets(item.NumberofReps, item.Weight);
         }
     }
 }
Exemplo n.º 5
0
 public void AddSession(string date)
 {
     using (var db = new GymTrackerContext())
     {
         var newSession = new Session()
         {
             UserId      = SelectedUser.UserId,
             ExerciseId  = SelectedExercise.ExerciseId,
             SessionDate = date
         };
         db.Sessions.Add(newSession);
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
        public void AddandSelectExerciseTest()
        {
            using (var db = new GymTrackerContext())
            {
                var selMusGro = db.MuscleGroups.Where(c => c.MuscleGroupId == 1).FirstOrDefault();
                crudManager.SelectMuscleGroup(selMusGro);
                var beforeNumberOfExercises = db.Exercises.ToList().Count();
                crudManager.AddandSelectExercise("Jumping");
                var afterNumberOfExercises = db.Exercises.ToList().Count();

                Assert.AreEqual(crudManager.SelectedExercise.ExerciseName, "Jumping");
                Assert.AreEqual(beforeNumberOfExercises + 1, afterNumberOfExercises);
            }
        }
Exemplo n.º 7
0
 public List <Session> ReadUserSessions()
 {
     using (var db = new GymTrackerContext())
     {
         var            allsessions  = db.Sessions.ToList();
         List <Session> userSessions = new List <Session>();
         foreach (var item in allsessions)
         {
             if (item.UserId == SelectedUser.UserId)
             {
                 userSessions.Add(item);
             }
         }
         return(userSessions);
     }
 }
Exemplo n.º 8
0
        public void TearDown()
        {
            using (var db = new GymTrackerContext())
            {
                var selectedCustomer =
                    from c in db.Users
                    where c.UserName == "Test-Vinay"
                    select c;

                foreach (var c in selectedCustomer)
                {
                    db.Users.Remove(c);
                }
                db.SaveChanges();
            }
        }
Exemplo n.º 9
0
 public List <Session> SWOverview(int userid, int fake)
 {
     using (var db = new GymTrackerContext())
     {
         List <Session> allSessions  = new List <Session>();
         List <Session> userSessions = new List <Session>();
         allSessions = db.Sessions.ToList();
         foreach (var item in allSessions)
         {
             if (item.UserId == userid)
             {
                 userSessions.Add(item);
             }
         }
         return(userSessions);
     }
 }
Exemplo n.º 10
0
        public List <Exercise> ReadExercise(int userid)
        {
            using (var db = new GymTrackerContext())
            {
                List <Session> allSessions = new List <Session>();
                allSessions = db.Sessions.ToList();

                List <Exercise> allExercise = new List <Exercise>();
                allExercise = db.Exercises.ToList();

                List <Exercise> userExercise = new List <Exercise>();

                foreach (var session in allSessions)
                {
                    bool addTo = true;
                    if (session.UserId == userid)
                    {
                        foreach (var exercise in allExercise)
                        {
                            if (exercise.ExerciseId == session.ExerciseId)
                            {
                                if (userExercise.Count() > 0)  //minimse
                                {
                                    foreach (var rep in userExercise)
                                    {
                                        if (rep == exercise)
                                        {
                                            addTo = false;
                                            break;
                                        }
                                    }
                                }

                                if (addTo == true)
                                {
                                    userExercise.Add(exercise);
                                }
                            }
                        }
                    }
                }

                return(userExercise);
            }
        }
Exemplo n.º 11
0
 public List <Set> ReadSessionSets()
 {
     using (var db = new GymTrackerContext())
     {
         List <Set> allSets     = db.Sets.ToList();
         List <Set> sessionSets = new List <Set>();
         if (SelectedSession != null)
         {
             foreach (var item in allSets)
             {
                 if (item.SessionId == SelectedSession.SessionId)
                 {
                     sessionSets.Add(item);
                 }
             }
         }
         return(sessionSets);
     }
 }
Exemplo n.º 12
0
        public void ReadUserSessionsTest()
        {
            using (var db = new GymTrackerContext())
            {
                var allSessions          = db.Users.ToList();
                var numberOfUserSessions = 0;
                foreach (var item in allSessions)
                {
                    if (item.UserId == crudManager.SelectedUser.UserId)
                    {
                        numberOfUserSessions++;
                    }
                }

                var resultFromMethod = crudManager.ReadUserSessions().Count();

                Assert.IsTrue(crudManager.SelectedSession != null);
                Assert.AreEqual(numberOfUserSessions, resultFromMethod);
            }
        }
Exemplo n.º 13
0
        public void Setup()
        {
            using (var db = new GymTrackerContext())
            {
                var selectedCustomer =
                    from c in db.Users
                    where c.UserName == "Test-Vinay"
                    select c;
                foreach (var c in selectedCustomer)
                {
                    db.Users.Remove(c);
                }
                db.SaveChanges();

                crudManager.AddandSelectUser("Test-Vinay");
                var selEx = db.Exercises.Where(e => e.ExerciseId == 1).FirstOrDefault();
                crudManager.SelectExercise(selEx);
                crudManager.AddandSelectSession("12-12-12"); //autoremoved when user removed
            }
        }
Exemplo n.º 14
0
 public void UpdateSets(int numofreps, int weight)
 {
     using (var db = new GymTrackerContext())
     {
         var SetWhy         = db.Sets.Where(c => c.SetId == SelectedSet.SetId).FirstOrDefault();
         var allSessionSets = ReadSessionSets();
         int renumber       = 1;
         foreach (var item in allSessionSets)
         {
             if (item.SetId == SetWhy.SetId)
             {
                 break;
             }
             renumber++;
         }
         SetWhy.SetNumber    = renumber;
         SetWhy.NumberofReps = numofreps;
         SetWhy.Weight       = weight;
         db.SaveChanges();
     }
 }
Exemplo n.º 15
0
        public void TearDown()
        {
            using (var db = new GymTrackerContext())
            {
                var selectedCustomer =
                    from c in db.Users
                    where c.UserName == "Test-Vinay"
                    select c;

                foreach (var c in selectedCustomer)
                {
                    db.Users.Remove(c);
                }

                db.SaveChanges();

                //var exercise = db.Exercises.Where(e => e.ExerciseName == "Jumping");
                //crudManager.SelectExercise(exercise);
                //crudManager.RemoveExercise();
            }
        }
 public DailyRoutineRepository(GymTrackerContext aspnet_GymTrackerContext)
 {
     _aspnetGymTrackerContext = aspnet_GymTrackerContext;
 }
Exemplo n.º 17
0
 public TraineeRepository(GymTrackerContext aspnet_GymTrackerContext)
 {
     _aspnetGymTrackerContext = aspnet_GymTrackerContext;
 }
Exemplo n.º 18
0
 public ExerciseRepository(GymTrackerContext context)
 {
     this.context = context;
 }
Exemplo n.º 19
0
        //////////////////////////////////////////////////////////////////////////////////////

        public (List <string>, List <int>, List <string>) SWOverview(int userid)
        {
            using (var db = new GymTrackerContext())
            {
                List <string> dates          = new List <string>();
                List <int>    totalExersices = new List <int>();
                List <string> ratios         = new List <string>();

                var allSessions =
                    from s in db.Sessions
                    join e in db.Exercises on s.ExerciseId equals e.ExerciseId
                    where s.UserId == userid
                    select new { s.SessionDate, e.MuscleGroupId };
                //int countChest = 0;
                //int countShoulders = 0;
                //int countBack= 0;
                //int countArms = 0;
                //int countLegs = 0; //for future feature - hopefully not
                foreach (var item in allSessions)
                {
                    if (dates.Count() > 0)
                    {
                        if (item.SessionDate == dates[dates.Count() - 1])
                        {
                            totalExersices[totalExersices.Count() - 1]++;
                            //ratios[ratios.Count() - 1] = ("1:1:0:0:0"); // for future feature
                        }
                    }

                    else
                    {
                        dates.Add(item.SessionDate);
                        totalExersices.Add(1);

                        /////na....
                        if (item.MuscleGroupId == 1)
                        {
                            ratios.Add("1:0:0:0:0"); // for future feature
                        }
                        else if (item.MuscleGroupId == 2)
                        {
                            {
                                ratios.Add("0:1:0:0:0"); // for future feature
                            }
                        }
                        else if (item.MuscleGroupId == 3)
                        {
                            {
                                ratios.Add("0:0:1:0:0"); // for future feature
                            }
                        }
                        else if (item.MuscleGroupId == 4)
                        {
                            {
                                ratios.Add("0:0:0:1:0"); // for future feature
                            }
                        }
                        else if (item.MuscleGroupId == 5)
                        {
                            {
                                ratios.Add("0:0:0:0:1"); // for future feature
                            }
                        }
                        ////na....
                    }
                }

                return(dates, totalExersices, ratios);
            }
        }
 public EventRepository(GymTrackerContext aspnet_GymTrackerContext)
 {
     _aspnetGymTrackerContext = aspnet_GymTrackerContext;
 }
Exemplo n.º 21
0
 public ExerciseRepository(GymTrackerContext aspnet_GymTrackerContext)
 {
     _aspnetGymTrackerContext = aspnet_GymTrackerContext;
 }
 public TraineeMeasurementsRepository(GymTrackerContext aspnet_GymTrackerContext)
 {
     _aspnetGymTrackerContext = aspnet_GymTrackerContext;
 }
 public UserProfileRepository(GymTrackerContext aspnet_GymTrackerContext)
 {
     _aspnetGymTrackerContext = aspnet_GymTrackerContext;
 }
Exemplo n.º 24
0
 public UserDetailsRepository(GymTrackerContext context)
 {
     this.context = context;
 }
 public DailyProgressRepository(GymTrackerContext aspnet_GymTrackerContext)
 {
     _aspnetGymTrackerContext = aspnet_GymTrackerContext;
 }