Ejemplo n.º 1
0
        public List <Lesson> LoadObjectList(string path)
        {
            TimeMananger Time = new TimeMananger();

            if (File.Exists(path) == false)
            {
                File.Create(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"SchoolSoft1v1Me\Schedule\" + Time.DayOfWeek + ".json"));
                Lesson templesson = new Lesson();
                Lesson.MyList.Add(templesson);
            }
            using (StreamReader reader = new StreamReader(path))
            {
                try
                {
                    var Templist = new List <Lesson>();
                    Templist = JsonConvert.DeserializeObject <List <Lesson> >(reader.ReadToEnd());
                    if (Templist.Count == 0)
                    {
                        var TempLesson = new Lesson();
                        Templist.Add(TempLesson);
                    }
                    return(Lesson.MyList);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    Console.WriteLine("Creating File for new day");
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
        public bool CurrentLessonSelect()
        {
            bool tempbool = true;

            do
            {
                TimeMananger time = new TimeMananger();
                int          i    = 0;
                if (Lesson.MyList.Count == 0)
                {
                    Lesson templesson = new Lesson();
                    Lesson.MyList.Add(templesson);
                }
                foreach (Lesson x in Lesson.MyList)
                {
                    if (Lesson.MyList[i].LessonEndTime < time.CT.AddHours(-1))
                    {
                        i += i;
                    }
                }
                if (i == 0 && Lesson.MyList[0].LessonEndTime < time.CT.AddHours(-1))
                {
                    Console.WriteLine("You are not currently in a lesson");
                    return(false);
                }
                else
                {
                    CurrentLesson = i;
                }
                tempbool = false;
                return(true);
            } while (tempbool == true);
        }
Ejemplo n.º 3
0
        public bool LessonCreate()
        {
            Lesson       tempLesson   = new Lesson();
            EventHandler HandleEvent  = new EventHandler();
            TimeMananger timeMananger = new TimeMananger();

            HandleEvent.StringReturn("What is the name of the Lesson?", out tempLesson.LessonName);
            timeMananger.ReturnDateTime("Which hour does the lesson end?", "Which Minute does the lesson end?", out tempLesson.LessonEndTime);
            Lesson.MyList.Add(tempLesson);
            return(true);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Filehandler  HandleFiles = new Filehandler();
            TimeMananger Time        = new TimeMananger();

            HandleFiles.LoadObjectList(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"SchoolSoft1v1Me\Schedule\" + Time.DayOfWeek + ".json"));
            //LessonManager ClassMananger = new LessonManager();
            //if (ClassMananger.CurrentLessonSelect() == true)
            //{
            //    Lesson templesson = Lesson.MyList[LessonManager.CurrentLesson];
            //    Console.WriteLine(templesson.LessonName + " ends in " + (templesson.LessonEndTime - Time.CT));
            //}
        }