Exemple #1
0
        private static void RemoveCourseGoal()
        {
            Course course = AskForCourseById();

            var goalStore = new GoalStore();

            List <Goal> goals = goalStore.FindByCourseId(course.CourseId).ToList();

            foreach (var goal in goals)
            {
                Console.WriteLine(goal.GoalId + ":  " + goal.Description.Truncate(Console.WindowWidth));
            }
            Console.WriteLine("Tryck enter för att avbryta");
            Console.WriteLine();
            string input = UserInput.GetInput <string>("Ange mål id");

            goals.RemoveAll(g => g.GoalId == input);
            goalStore.Remove(input);

            for (int i = 0; i < goals.Count; i++)
            {
                goals[i].GoalId = (i + 1).ToString();
            }
            goalStore.Save();
        }
Exemple #2
0
        private static void EditCourseGoal()
        {
            Course course    = AskForCourseById();
            var    goalStore = new GoalStore();

            List <Goal> goals = goalStore.FindByCourseId(course.CourseId).ToList();

            foreach (var g in goals)
            {
                Console.WriteLine(g.GoalId + ":  " + g.Description.Truncate(Console.WindowWidth));
            }

            UserInput.WaitForContinue();
            Console.WriteLine();
            string input = UserInput.GetInput <string>("Ange mål-id:");

            Console.Clear();
            Goal goal = goals.SingleOrDefault(g => g.GoalId == input);

            if (goal != null)
            {
                Console.WriteLine("Gammal beskrivning: " + goal.Description);
                Console.WriteLine();
                goal.Description = UserInput.GetInput <string>("Den studerande ska: ");
                goalStore.Save();
            }
            else
            {
                Console.WriteLine("Målet finns inte");
            }
        }
Exemple #3
0
        private static void CreateNewCourseGoal()
        {
            var goalStore = new GoalStore();

            Console.Clear();
            Console.WriteLine("Skapa nytt mål för kurs");
            Console.WriteLine();

            Course course = AskForCourseById();

            if (course == null)
            {
                return;
            }

            Console.Clear();
            Console.WriteLine($"Kurs: {course.CourseName} ({course.CourseId})");

            int goalCount = goalStore.FindByCourseId(course.CourseId).Count();

            Console.WriteLine("Tryck enter för att avbryta");
            Console.WriteLine();
            while (true)
            {
                string description = UserInput.GetInput <string>("Den studerande ska:");

                if (description == string.Empty)
                {
                    break;
                }

                var goal = new Goal
                {
                    CourseId    = course.CourseId,
                    GoalId      = (goalCount + 1).ToString(),
                    Description = description
                };
                goalCount++;
                goalStore.AddItem(goal);
                goalStore.Save();
            }
            ShowCourseGoals(course);
        }