Esempio n. 1
0
        public static void addNewGoal(string Name, decimal Target, string Description, string ImagePath, DateTime endTime)
        {
            goal goalToSave = new goal();

            goalToSave.name   = Name;
            goalToSave.target = Target;
            String TargetToDisplay = string.Format("Target: {0:C}", Target);

            goalToSave.targetToDisplay = TargetToDisplay;
            goalToSave.description     = Description;
            goalToSave.targetReached   = 0;
            if (ImagePath != null)
            {
                goalToSave.imagePath = ImagePath;
            }
            else
            {
                goalToSave.imagePath = "ms-appx:///Assets/noImage.png";
            }


            goalToSave.progress = "Progress: 0%";
            goalToSave.tileID   = generateUniqueID();

            if (endTime != noTimeLimitDate)
            {
                goalToSave.endTime = endTime;
                goalToSave.unitsOfTimeRemaining = determineTimeLeft(goalToSave);
            }



            listOfGoals.Add(goalToSave);
        }
Esempio n. 2
0
        public static void replaceGoal(goal changedGoal)
        {
            List <goal> goalContainer = goal.listOfGoals.Where(p => p.name == changedGoal.name).ToList();
            goal        goalToReplace = goalContainer[0];
            int         index         = goal.listOfGoals.IndexOf(goalToReplace);

            if (index != -1)
            {
                goal.listOfGoals[index] = changedGoal;
            }
        }
Esempio n. 3
0
        public static string determineTimeLeft(goal goalItem)
        {
            int  calculation;
            int  remainder;
            bool yearsMatch  = false;
            bool monthsMatch = false;
            bool daysMatch   = false;

            calculation = goalItem.endTime.Year - DateTime.Now.Year;
            if (calculation <= 0)
            {
                yearsMatch = true;
            }

            if (yearsMatch == true)
            {
                calculation = goalItem.endTime.Month - DateTime.Now.Month;
                if (calculation <= 0)
                {
                    monthsMatch = true;
                }
            }

            if (monthsMatch == true)
            {
                calculation = goalItem.endTime.Day - DateTime.Now.Day;

                if (calculation <= 0)
                {
                    daysMatch = true;
                }
            }

            string timeLeftDescription = "";

            if (daysMatch == true)
            {
                timeLeftDescription = "No more time left.";
            }
            else
            {
                remainder           = calculation;
                timeLeftDescription = determineDescriptionToReturn(timeLeftDescription, yearsMatch, monthsMatch, remainder);
            }


            return(timeLeftDescription);
        }
Esempio n. 4
0
        public static void makeCompletedGoal(goal achievedGoal, DateTime DateOfCompletion)
        {
            completedGoal completeGoalToSave = new completedGoal();

            completeGoalToSave.name             = achievedGoal.name;
            completeGoalToSave.target           = achievedGoal.target;
            completeGoalToSave.imagePath        = achievedGoal.imagePath;
            completeGoalToSave.description      = achievedGoal.description;
            completeGoalToSave.targetReached    = achievedGoal.targetReached;
            completeGoalToSave.dateOfCompletion = DateOfCompletion;
            completeGoalToSave.progress         = "Progress: 100%";
            completeGoalToSave.targetToDisplay  = achievedGoal.targetToDisplay;
            List <goal> goalToRemove = listOfGoals.Where(p => p.name == achievedGoal.name).ToList();

            listOfGoals.Remove(goalToRemove[0]);
            listOfCompletedGoals.Add(completeGoalToSave);
        }