Example #1
0
        public static bool DeleteCard(string[] com)
        {
            if (com.Length < 4)
            {
                return(false);
            }
            if (com[0] != "delete")
            {
                return(false);
            }
            if (com[1] != "card")
            {
                return(false);
            }
            DateTime origDt;
            Card     card;
            int      deadlineIndex;
            bool     found = false;
            string   firstPart;

            if (com[2] == "null")
            {
                firstPart = "0:0:0";
            }
            else
            {
                firstPart = com[2];
            }
            bool ok = Schedule.DateTimeFromString(firstPart + "-" + com[3], out origDt);

            if (!ok)
            {
                Conzole.PrintLine("Your date/time is incorrect!", ConsoleColor.Red);
                return(false);
            }
            found = Schedule.cards.Get(origDt, com[2] == "null", out card, out deadlineIndex);
            if (!found)
            {
                Conzole.PrintLine("Could not find card!", ConsoleColor.Red);
                return(false);
            }
            Conzole.PrintLine("Deleting card " + card.title + ".", ConsoleColor.Magenta);
            bool sure = Conzole.AreYouSure();

            if (!sure)
            {
                Conzole.PrintLine("Did not delete anything.", ConsoleColor.Magenta);
                return(false);
            }
            Schedule.cardsArchive.Add(card);
            Schedule.cardsArchive.Write();
            Schedule.cards.Delete(card);
            Schedule.cards.Write();
            Conzole.PrintLine("Succes!", ConsoleColor.Magenta);
            return(true);
        }
Example #2
0
        public static bool CleanCards(string[] com)
        {
            if (com.Length < 2)
            {
                return(false);
            }
            if (com[0] != "clean")
            {
                return(false);
            }
            if (com[1] != "cards")
            {
                return(false);
            }
            Conzole.PrintLine("Deleting all cards that are past.");
            bool ok = Conzole.AreYouSure();

            if (!ok)
            {
                Conzole.PrintLine("Did not delete anything.", ConsoleColor.Magenta);
                return(true);
            }
            DateTime    limit = DateTime.Now.AddSeconds(-1);
            CardFile    cf    = Schedule.cards;
            List <Card> dls   = new List <Card>();

            for (int i = 0; i < cf.Size(); i++)
            {
                Card c = cf.Get(i);
                if (c.end <= limit)
                {
                    dls.Add(c);
                }
            }
            for (int i = 0; i < dls.Count; i++)
            {
                Schedule.cardsArchive.Add(dls[i]);
                cf.Delete(dls[i]);
            }
            Schedule.cardsArchive.Write();
            cf.Write();
            Conzole.PrintLine("Succes!", ConsoleColor.Magenta);
            return(false);
        }
Example #3
0
        public static bool CleanDeadlines(string[] com)
        {
            if (com.Length < 2)
            {
                return(false);
            }
            if (com[0] != "clean")
            {
                return(false);
            }
            if (com[1] != "deadlines")
            {
                return(false);
            }
            Conzole.PrintLine("Deleting all deadlines that are past.");
            bool ok = Conzole.AreYouSure();

            if (!ok)
            {
                Conzole.PrintLine("Did not delete anything.", ConsoleColor.Magenta);
                return(true);
            }
            DateTime        limit = DateTime.Now.AddSeconds(-1);
            DeadlineFile    df    = Schedule.deadlines;
            List <Deadline> dls   = new List <Deadline>();

            for (int i = 0; i < df.Size(); i++)
            {
                Deadline d = df.Get(i);
                if (d.deadline <= limit)
                {
                    dls.Add(d);
                }
            }
            for (int i = 0; i < dls.Count; i++)
            {
                Schedule.deadlinesArchive.Add(dls[i]);
                df.Delete(dls[i]);
            }
            Schedule.deadlinesArchive.Write();
            df.Write();
            Conzole.PrintLine("Succes!", ConsoleColor.Magenta);
            return(false);
        }
Example #4
0
        public static bool DeleteTimeSlot(string[] com)
        {
            if (com.Length < 3)
            {
                return(false);
            }
            if (com[0] != "delete")
            {
                return(false);
            }
            if (com[1] != "timeslot")
            {
                return(false);
            }
            TimeSlot slot;
            bool     found = Schedule.timeslots.Get(com[2], out slot);

            if (!found)
            {
                Conzole.PrintLine("Could not find timeslot!", ConsoleColor.Red);
                return(false);
            }
            Conzole.PrintLine("Deleting timeslot " + slot.name + ".", ConsoleColor.Magenta);
            bool sure = Conzole.AreYouSure();

            if (!sure)
            {
                Conzole.PrintLine("Did not delete anything.", ConsoleColor.Magenta);
                return(false);
            }
            Schedule.timeslotsArchive.Add(slot);
            Schedule.timeslotsArchive.Write();
            Schedule.timeslots.Delete(slot);
            Schedule.timeslots.Write();
            Conzole.PrintLine("Succes!", ConsoleColor.Magenta);
            return(true);
        }