public IHttpActionResult Add([FromBody] ToDoRequest model)
        {
            var toDomanager = new ToDoList.ToDoList();

            toDomanager.AddToDo(model.title, model.content);
            return(Json(new { Result = "success" }));
        }
        public IHttpActionResult Delete([FromBody] ToDoRequest model)
        {
            var toDomanager = new ToDoList.ToDoList();

            toDomanager.DeleteToDo(model.id);

            return(Json(new { Result = "success" }));
        }
Beispiel #3
0
        public void AddItem_AddingInvalidItem()
        {
            ToDoList toDoList = new ToDoList();

            IItem invalidItem = this.GetMockIItem(isValid: false);

            Assert.IsFalse(toDoList.AddItem(invalidItem));
            Assert.IsFalse(toDoList.items.Contains(invalidItem));
        }
Beispiel #4
0
        public void AddItem_AddingValidItem()
        {
            ToDoList toDoList = new ToDoList();

            IItem validItem = this.GetMockIItem(isValid: true);

            Assert.IsTrue(toDoList.AddItem(validItem));
            Assert.IsTrue(toDoList.items.Contains(validItem));
        }
        public void LoadTaskList(ToDoList list)
        {
            OpenFileDialog theDialog = new OpenFileDialog();

            theDialog.Title            = "Open existing to-do list?";
            theDialog.Filter           = "TXT files|*.txt";
            theDialog.InitialDirectory = @".";
            if (theDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string filename = theDialog.FileName;
                    System.Console.WriteLine("Reading file {0}", filename);
                    StreamReader file    = new StreamReader(filename);
                    int          counter = 0;
                    string       line;
                    string       status;
                    bool         taskIsDone;
                    string       description;

                    while ((line = file.ReadLine()) != null)
                    {
                        System.Console.WriteLine(line);
                        string[] taskElements = line.Split(',');
                        status      = taskElements[0];
                        description = taskElements[1];
                        if (status == "False")
                        {
                            taskIsDone = false;
                        }
                        else
                        {
                            taskIsDone = true;
                        }

                        if (taskElements.Length == 2)
                        {
                            list.AddTaskToList(description, taskIsDone);
                        }
                        else
                        {
                            MessageBox.Show("There is an error in the ToDoList.txt file.  It is not in the proper format.");
                        }

                        counter++;
                    }

                    file.Close();
                    System.Console.WriteLine("There were {0} lines.", counter);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file.  Error: " + ex.Message);
                }
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            ToDoList t = new ToDoList();

            t.AggiungiToDo("porta fuori il cane", 0);
            t.AggiungiToDo("mangia pizza", 1);
            t.AggiungiToDo("gioca pc", 8);

            t.ViewList();
        }
Beispiel #7
0
        public void IsItemCreationPossible_LastItemCreatedTenMinutesAgo()
        {
            ToDoList toDoList = new ToDoList();

            IItem itemCreatedTenMinutesAgo = this.GetMockIItem(isValid: true, creationDate: DateTime.Now.Subtract(new TimeSpan(0, 10, 0)));

            toDoList.AddItem(itemCreatedTenMinutesAgo);

            Assert.IsFalse(toDoList.IsItemCreationPossible());
        }
Beispiel #8
0
        /* Instructies
         * Maak een applicatie ToDoList. De applicatie ToDoList heeft een class ToDoList.
         * De class ToDoList heeft een instance variabele producten, wat een array is.
         * Het arrayobject, bevat objecten van het type Product.
         * De class product heeft de string naam en de int aantal als attributen. Maak de class product abstract.
         * Maak van product twee subclasses, namelijk BuyFood en Shopping en initialiseert in de subclasses voor ieder attribuut een waarde.
         * Laat in een demo-applicatie zien dat er BuyFood en Shopping in de ToDoList geplaatst kunnen worden. */

        public static void Main(string[] args)
        {
            ToDoList tasks = new ToDoList();

            tasks.AddTask(new BuyFood());
            tasks.AddTask(new Shopping());
            foreach (var toDoTask in tasks.task)
            {
                Console.WriteLine($"The task is {toDoTask.Naam()} and the amount is {toDoTask.Aantal()}");
            }
            Console.ReadLine();
        }
Beispiel #9
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            ToDoList newTask = new ToDoList(Uid, NameTB.Text,
                                            SpecificationTB.Text, DeadLinePicker.Value.ToString("yyyy-MM-dd"), "не начато",
                                            PriorityNum.Value.ToString(), URLTB.Text);
            MySQLConnectionString connStr = new MySQLConnectionString("localhost", "root", "root", "testDB");
            MySQLDBConnection     mySQLDB = new MySQLDBConnection(connStr);

            INSERT insertTask = new INSERT(mySQLDB);

            insertTask.Insert(newTask);
        }
        public IHttpActionResult GetToDos()
        {
            //さすがにハイジャックはされたくなのでむき出しの配列では返さない。
            var toDoList = new ToDoList.ToDoList().GetToDos()
                           .Select(t => new ToDo {
                id = t.Id, title = t.Title, content = t.Content
            })
                           .ToList();

            return(Json(new ListModel {
                UserList = toDoList
            }));
        }
Beispiel #11
0
        public void IsItemCreationPossible()
        {
            ToDoList toDoList = new ToDoList();

            IItem itemCreatedTwoHoursAgo = this.GetMockIItem(isValid: true, creationDate: DateTime.Now.Subtract(new TimeSpan(2, 0, 0)));

            toDoList.AddItem(itemCreatedTwoHoursAgo);
            IItem itemCreatedOneHoursAgo = this.GetMockIItem(isValid: true, creationDate: DateTime.Now.Subtract(new TimeSpan(1, 0, 0)));

            toDoList.AddItem(itemCreatedOneHoursAgo);

            Assert.IsTrue(toDoList.IsItemCreationPossible());
        }
Beispiel #12
0
        public void IsItemCreationPossible_TenItemsOrMoreInTheList()
        {
            ToDoList toDoList = new ToDoList();

            for (int i = 0; i < 10; i += 1)
            {
                IItem item = this.GetMockIItem(isValid: true);
                toDoList.AddItem(item);

                Assert.IsTrue(toDoList.items.Contains(item));
            }

            Assert.IsFalse(toDoList.IsItemCreationPossible());
        }
Beispiel #13
0
        private void List_SaveList()
        {
            ToDoList testList = new ToDoList();

            testList.AddTaskToList("List_SaveList One");
            testList.MarkTaskAsDone(0);
            testList.AddTaskToList("List_SaveList Two");
            testList.MarkTaskAsNotCompleted(1);
            testList.AddTaskToList("List_SaveList Three");
            testList.MarkTaskAsDone(2);

            ListIO listIO = new ListIO();

            listIO.SaveTaskList(testList.Tasks);
        }
Beispiel #14
0
        public void MailSender_MailHasNotBeenSent()
        {
            ToDoList toDoList = new ToDoList();

            for (int i = 0; i < 7; i += 1)
            {
                IItem newItem = this.GetMockIItem(isValid: true);
                toDoList.AddItem(newItem);

                Assert.IsTrue(toDoList.items.Contains(newItem));
            }

            Assert.AreEqual(toDoList.items.Count, 7);
            Assert.IsFalse(toDoList.mailSent);
        }
Beispiel #15
0
        private void List_LoadList()
        {
            // This test is fragile as it relies on having the list from List_SaveList already
            // run.  Better would be for it to pull in a separate file, but that would
            // require modifying ListIOFunctions.LoadTaskList to suppoort having a filename
            ToDoList testList = new ToDoList();
            ListIO   listIO   = new ListIO();

            listIO.LoadTaskList(testList);
            testList.Tasks[0].Description.ShouldBe("List_SaveList One");
            testList.Tasks[0].IsDone.ShouldBe(true);
            testList.Tasks[1].Description.ShouldBe("List_SaveList Two");
            testList.Tasks[1].IsDone.ShouldBe(false);
            testList.Tasks[2].Description.ShouldBe("List_SaveList Three");
            testList.Tasks[2].IsDone.ShouldBe(true);
        }
Beispiel #16
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FillItemListBox();
            frmAddDetails details = new frmAddDetails();

            details.ShowDialog();
            ToDoList item = null;

            item = details.item;
            if (!details.cancel)
            {
                lbList.Items.Add(item.displayText());
                lists.Add(item);
                file.SaveItems(lists, true);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Метод для удаления задачи по ID
        /// </summary>
        /// <param name="id"></param>
        public void Delete(int id)
        {
            try
            {
                ToDoList.Remove(ToDoList[--id]);
            }
            catch (Exception)
            {
                Console.WriteLine("Ошибка. Введите номер задачи, которую вы хотите удалить");
            }

            for (int i = 1; i < ToDoList.Count; i++)
            {
                ToDoList[i].Id = ++i;
            }
        }
Beispiel #18
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FillItemListBox();
            frmExpandDetails details = new frmExpandDetails();

            details.ShowDialog();
            ToDoList item = null;

            item = details.item;
            if (!details.cancel)
            {
                lbList.Items.Add(item.Details);
                lists.Add(item);
                secondFile.SaveItems(lists, false);
            }
        }
Beispiel #19
0
        public void IsValid()
        {
            ToDoList toDoList = new ToDoList();

            IItem firstItem = this.GetMockIItem(isValid: true);

            toDoList.AddItem(firstItem);
            IItem secondItem = this.GetMockIItem(isValid: true, creationDate: DateTime.Now.Subtract(new TimeSpan(1, 0, 0)));

            toDoList.AddItem(secondItem);
            IItem thirdItem = this.GetMockIItem(isValid: true, name: "thirdItem", creationDate: DateTime.Now);

            toDoList.AddItem(thirdItem);

            Assert.IsTrue(toDoList.items.Contains(firstItem));
            Assert.IsTrue(toDoList.items.Contains(secondItem));
            Assert.IsTrue(toDoList.items.Contains(thirdItem));
            Assert.IsTrue(toDoList.IsValid());
        }
Beispiel #20
0
        public void IsValid_ContainsAnInvalideItem()
        {
            ToDoList toDoList = new ToDoList();

            IItem firstItem = this.GetMockIItem(isValid: true);

            toDoList.AddItem(firstItem);
            IItem secondItem = this.GetMockIItem(isValid: false, creationDate: DateTime.Now.Subtract(new TimeSpan(1, 0, 0)));

            toDoList.items.Add(secondItem); // Force pushing with List.Add, otherwise Additem would not add an invalid item to the list
            IItem thirdItem = this.GetMockIItem(isValid: true, name: "thirdItem", creationDate: DateTime.Now);

            toDoList.AddItem(thirdItem);

            Assert.IsTrue(toDoList.items.Contains(firstItem));
            Assert.IsTrue(toDoList.items.Contains(secondItem));
            Assert.IsTrue(toDoList.items.Contains(thirdItem));
            Assert.IsFalse(toDoList.IsValid());
        }
Beispiel #21
0
        public void IsValid_ContainsMoreThanTenItems()
        {
            ToDoList toDoList = new ToDoList();

            for (int i = 0; i < 10; i += 1)
            {
                IItem newItem = this.GetMockIItem(isValid: true);
                toDoList.AddItem(newItem);

                Assert.IsTrue(toDoList.items.Contains(newItem));
            }

            IItem eleventhItem = this.GetMockIItem(isValid: true);

            toDoList.items.Add(eleventhItem); // Force pushing with List.Add, otherwise Additem would not add an eleventh item to the list

            Assert.IsTrue(toDoList.items.Contains(eleventhItem));
            Assert.IsFalse(toDoList.IsValid());
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            try
            {
                string filePath = "ToDoList.txt";
                Console.WindowHeight = 45;
                if (!File.Exists(filePath))
                {
                    using (File.CreateText(filePath)) { }
                }

                myToDoList = new ToDoList(filePath);

                MainMenu();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #23
0
        public static void Main()
        {
            ToDo t1 = new ToDo("Lipo lisur laso darius", DateTime.Now, Priority.Low);
            ToDo t2 = new ToDo("Lipo lisur laso darius", DateTime.Now, Priority.High);
            ToDo t3 = new ToDo("Lipo lisur laso darius", DateTime.Now, Priority.Medium);

            ToDoList tdl1 = new ToDoList("Daniel");

            try
            {
                tdl1.AddToDo(t1);
                tdl1.AddToDo(t2);
                tdl1.AddToDo(t3);
            }
            catch
            {
                throw new ArgumentException("Adding to todolist failed");
            }


            Console.WriteLine(tdl1.ToString());
        }
Beispiel #24
0
        public List <ToDoList> GetItems(bool firstFile)
        {
            // create the list
            List <ToDoList> items = new List <ToDoList>();

            // create the XmlReaderSettings object
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;
            settings.IgnoreComments   = true;

            // create the XmlReader object

            XmlReader xmlIn = XmlReader.Create(Path, settings);

            // read past all nodes to the first Book node
            if (xmlIn.ReadToDescendant("ToDoList"))
            {
                // create one Product object for each Product node
                do
                {
                    ToDoList list = new ToDoList();
                    xmlIn.ReadStartElement("ToDoList");
                    if (firstFile)
                    {
                        list.date = xmlIn.ReadElementContentAsString();
                    }
                    list.details = xmlIn.ReadElementContentAsString();
                    items.Add(list);
                }while (xmlIn.ReadToNextSibling("ToDoList"));
            }

            // close the XmlReader object
            xmlIn.Close();

            return(items);
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            ToDoList toDoList = new ToDoList();

            while (true)
            {
                Console.Clear();
                Console.WriteLine($"There are {toDoList.ToDoCount()} To-Do's on your list. You have completed {toDoList.DoneCount()} To-Do's");
                toDoList.PrintToDos();
                Console.WriteLine();

                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1. Add a new to-do");
                Console.WriteLine("2. Complete a to-do");
                Console.WriteLine("3. Show completed to-do's");
                Console.WriteLine("4. Delete a to-do");
                Console.WriteLine("Q. Quit");
                string input = (Console.ReadLine());

                switch (input.ToUpper())
                {
                case "1":
                    Console.WriteLine("Enter a task description:");
                    string description = Console.ReadLine();
                    Console.WriteLine("Enter a due date:");
                    if (!DateTime.TryParse(Console.ReadLine(), out DateTime dueDate))
                    {
                        dueDate = DateTime.Today;
                    }
                    toDoList.AddToDo(description, dueDate);
                    break;

                case "2":
                    Console.WriteLine("Great job! Enter the number of the To-Do you completed:");
                    if (int.TryParse(Console.ReadLine(), out int index))
                    {
                        toDoList.MarkComplete(index);
                    }
                    break;

                case "3":
                    Console.WriteLine();
                    Console.WriteLine("You completed the following to-do's, great job!");
                    toDoList.PrintCompleted();
                    Console.WriteLine();
                    Console.WriteLine("Press ENTER to return to main menu...");
                    Console.ReadLine();
                    break;

                case "4":
                    Console.WriteLine("Enter the number of the To-Do you want to delete:");
                    if (int.TryParse(Console.ReadLine(), out int index2))
                    {
                        toDoList.Delete(index2);
                    }
                    break;

                case "Q":
                    return;

                default:
                    break;
                }
            }
        }
Beispiel #26
0
 /// <summary>
 /// Копирование данных массива в список
 /// </summary>
 /// <param name="array"></param>
 /// <param name="index"></param>
 public void CopyTo(ToDoItem[] array, int index)
 {
     ToDoList.CopyTo(array, index);
 }
Beispiel #27
0
 /// <summary>
 /// Метод для создания новой задачи
 /// </summary>
 /// <param name="toDoItem"></param>
 public void Post(ToDoItem toDoItem)
 {
     ToDoList.Add(toDoItem);
 }
Beispiel #28
0
 /// <summary>
 /// Внедрение поддержки цикла foreach в класс
 /// </summary>
 /// <returns></returns>
 public IEnumerator GetEnumerator()
 {
     return(ToDoList.GetEnumerator());
 }
Beispiel #29
0
 IEnumerator <ToDoItem> IEnumerable <ToDoItem> .GetEnumerator()
 {
     return(ToDoList.GetEnumerator());
 }
Beispiel #30
0
 /// <summary>
 /// Удаление элемента из списка
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Remove(ToDoItem item)
 {
     return(ToDoList.Remove(item));
 }