Exemplo n.º 1
0
    public void AddWorkoutToCalendar(string CurrentWorkoutName, System.DateTime Today)
    {
        DayWorkoutData tempDayWorkoutData = new DayWorkoutData();

        tempDayWorkoutData.WorkoutName        = CurrentWorkoutName;
        tempDayWorkoutData.WorkoutCompleted   = false;
        tempDayWorkoutData.CompletedDateTime  = System.DateTime.Now;
        tempDayWorkoutData.TotalWorkoutTime   = 0;
        tempDayWorkoutData.TotalWorkoutWeight = 0;

        int DayIndex = -1;

        //int NameIndex = -1;
        for (int index = 0; index < UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day.Length; index++)
        {
            if ((Today.Year == UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day[index].Day.Year) &&
                (Today.Month == UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day[index].Day.Month) &&
                (Today.Day == UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day[index].Day.Day))
            {
                DayIndex = index;
                for (int WorkoutNameIndex = 0; WorkoutNameIndex < UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day[index].DayWorkoutArray.Length; WorkoutNameIndex++)
                {
                    if (CurrentWorkoutName == UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day[index].DayWorkoutArray[WorkoutNameIndex].WorkoutName)
                    {
                        //NameIndex = WorkoutNameIndex;
                    }
                }
            }
        }

        if (DayIndex < 0)
        {
            // add new day
            DayData tempDayData = new DayData();
            tempDayData.Day = Today;
            tempDayData.Add(tempDayWorkoutData);
            UserBlobManager.GetComponent <UserBlobManager> ().UserDayData.Add(tempDayData);
            UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day = UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day.OrderBy(x => x.Day).ToArray();
            UserBlobManager.GetComponent <UserBlobManager> ().SaveDay();
        }
        else
        {
            UserBlobManager.GetComponent <UserBlobManager>().UserDayData.Day[DayIndex].Add(tempDayWorkoutData);
            UserBlobManager.GetComponent <UserBlobManager>().SaveDay();

            /*
             * if (NameIndex < 0)
             *          {
             *                  //new workout
             *  //UserBlobManager.GetComponent<UserBlobManager>().UserDayData.Day[DayIndex].DayWorkoutArray.Add(tempDayWorkoutData);
             *                  UserBlobManager.GetComponent<UserBlobManager>().UserDayData.Day[DayIndex].Add(tempDayWorkoutData);
             *                  UserBlobManager.GetComponent<UserBlobManager> ().SaveDay ();
             *          }
             *          else
             *          {
             *                  // workout already exists, change completed bool and time
             *                  //UserBlobManager.GetComponent<UserBlobManager>().UserDayData[DayIndex].DayWorkoutArray[NameIndex].CompletedDateTime = Today;
             *                  //UserBlobManager.GetComponent<UserBlobManager>().UserDayData[DayIndex].DayWorkoutArray[NameIndex].WorkoutCompleted = false;
             *                  UserBlobManager.GetComponent<UserBlobManager> ().SaveDay ();
             *          }
             */
        }
    }