예제 #1
0
 internal int Delete(ToDoItem toRemove)
 {
     return(_connection.Delete <ToDoItem>(toRemove.Id));
 }
예제 #2
0
        private void AddDummyData()
        {
            ToDoItem item = new ToDoItem("First item", true);

            this._dataSource.Items.Add(item);
        }
예제 #3
0
 internal int Add(ToDoItem newItem)
 {
     return(_connection.Insert(newItem));
 }
예제 #4
0
        /// <summary>
        /// Метод для ввода команды
        /// </summary>
        /// <param name="readLine"></param>
        /// <param name="toDo"></param>
        /// <param name="toDoList"></param>
        /// <returns></returns>
        public static bool ReadCommand(string readLine, ToDo toDo, List <ToDoItem> toDoList)
        {
            if (readLine == "/post")
            {
                var postToDoItem = new ToDoItem();

                postToDoItem.Id = 1 + toDoList.Count;

                Console.WriteLine("Введите дату начала выполнения задачи");
                try
                {
                    postToDoItem.Start = DateTime.ParseExact(Console.ReadLine(), parseFormat, cultureInfo);
                }
                catch (Exception)
                {
                    Console.WriteLine("Ошибка. Введите дату начала выполнения задачи");
                    postToDoItem.Start = DateTime.ParseExact(Console.ReadLine(), parseFormat, cultureInfo);
                }

                Console.WriteLine("Введите дату окончания выполнения задачи");
                try
                {
                    postToDoItem.End = DateTime.ParseExact(Console.ReadLine(), parseFormat, cultureInfo);
                }
                catch (Exception)
                {
                    Console.WriteLine("Ошибка. Введите дату начала выполнения задачи");
                    postToDoItem.End = DateTime.ParseExact(Console.ReadLine(), parseFormat, cultureInfo);
                }

                Console.WriteLine("Введите содержимое задачи");
                postToDoItem.Content = Console.ReadLine();

                toDo.Post(postToDoItem);
                SerializeToJson(toDo);

                return(true);
            }
            else if (readLine == "/delete")
            {
                Console.WriteLine("Введите номер задачи, которую вы хотите удалить");

                var id = int.Parse(Console.ReadLine());
                toDo.Delete(id);

                SerializeToJson(toDo);

                return(true);
            }
            else if (readLine == "/patch content")
            {
                Console.WriteLine("Введите номер задачи, которую вы хотите изменить");
                var id = int.Parse(Console.ReadLine());

                Console.WriteLine("Введите изменённое содержимое");
                var content = Console.ReadLine();

                toDo.UpdateContent(id, content);

                SerializeToJson(toDo);

                return(true);
            }
            else if (readLine == "/patch data start")
            {
                Console.WriteLine("Введите номер задачи, которую вы хотите изменить");
                var id = int.Parse(Console.ReadLine());

                Console.WriteLine("Введите изменённую дату начала выполнения в формате dd.mm.yyyy. Например : 04.06.2005");
                var start = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", cultureInfo);

                toDo.UpdateStart(id, start);

                SerializeToJson(toDo);

                return(true);
            }
            else if (readLine == "/patch data end")
            {
                Console.WriteLine("Введите номер задачи, которую вы хотите изменить");
                var id = int.Parse(Console.ReadLine());

                Console.WriteLine("Введите изменённую дату конца выполнения в формате dd.mm.yyyy. Например : 04.06.2005");
                var end = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", cultureInfo);

                toDo.UpdateEnd(id, end);

                SerializeToJson(toDo);

                return(true);
            }
            else if (readLine == "/close")
            {
                Environment.Exit(0);
            }

            return(false);
        }
예제 #5
0
        static void Main(string[] args)
        {
            List <ToDoItem> todoList = new List <ToDoItem>();
            string          fileName = "todo.csv";
            string          filePath = ".\\" + fileName;

            try
            {
                string[] todoFile = File.ReadAllLines(filePath);

                foreach (string line in todoFile)
                {
                    string[] itens  = line.Split(",");
                    string   titulo = itens[0].Replace("\"", "");
                    string   nota   = itens[1].Replace("\"", "");

                    ToDoItem todoItem = new ToDoItem(titulo, nota);
                    todoList.Add(todoItem);
                }
            }

            catch (IOException ioe)
            {
                System.Console.WriteLine("Erro ao acessar arquivo");
                System.Console.WriteLine(ioe.Message);
            }

            int opcao;

            do
            {
                Console.Clear();
                System.Console.WriteLine("To Do List");
                System.Console.WriteLine();
                ListaItens(todoList);
                System.Console.WriteLine();
                System.Console.WriteLine("Digite uma opção");
                System.Console.WriteLine(" 1 - Adicionar Item");
                System.Console.WriteLine(" 2 - Remover Item");
                System.Console.WriteLine(" 3 - Sair do programa");
                System.Console.WriteLine("Opção: ");
                opcao = int.Parse(Console.ReadLine());

                switch (opcao)
                {
                case 1:
                    Additem(todoList);
                    break;

                case 2:
                    RemoveItem(todoList);
                    break;

                case 3:
                    System.Console.WriteLine("Tchau!");
                    break;

                default:
                    System.Console.WriteLine("Opção inválida");
                    Console.ReadLine();

                    break;
                }
            } while(opcao != 3);
        }
예제 #6
0
        public string ToDoDetail(int id)
        {
            ToDoItem t = _toDoList[id - 1];

            return($"#{t.Id}. ToDo di {t.UtenteId} \n {t.Completato}: {t.Descrizione}");
        }
예제 #7
0
        void commandLines(List <ToDoItem> toDoList)
        {
            // Udskriv listen med opgaver
            Console.WriteLine("Todo liste:");
            foreach (var todo in toDoList)
            {
                Console.WriteLine(todo);
            }

            // Assign string array from the enum to variable commands
            var commands = Enum.GetNames(typeof(TaskList));

            Console.WriteLine("\r\nCommands:");

            // Loop through the names in commands
            int i = 1;

            foreach (var command in commands)
            {
                Console.Write(command + " = " + i + ", ");
                i++;
            }


            Console.WriteLine("\r\nSkriv din næste command..");

            var      consoleCommand = int.Parse(Console.ReadLine());
            ToDoItem item           = new ToDoItem();



            if (consoleCommand == 1)
            {
                Console.WriteLine("Hvilken opgaves status vil du opdatere?");
                int itemIndex = int.Parse(Console.ReadLine());
                foreach (var itemStatus in toDoList)
                {
                    if (itemStatus.Id == itemIndex)
                    {
                        itemStatus.IsDone = !itemStatus.IsDone;
                    }
                }
                Console.WriteLine("Change status");
            }
            else if (consoleCommand == 2)
            {
                Console.WriteLine("Hvilken opgave vil du tilføje?");
                item.Id   = toDoList.Count + 1;
                item.Name = Console.ReadLine();
                toDoList.Add(item);
            }
            else if (consoleCommand == 3)
            {
                Console.WriteLine("Hvilken opgave vil du fjerne?");
                int itemIndex = int.Parse(Console.ReadLine()) - 1;
                toDoList = remove(itemIndex, toDoList);
            }
            else if (consoleCommand == 4)
            {
                Console.WriteLine("Hvilken af opgaverne vil du ændre?");
                int itemIndex = int.Parse(Console.ReadLine());
                foreach (var itemChange in toDoList)
                {
                    if (itemChange.Id == itemIndex)
                    {
                        Console.WriteLine("Skriv ny tekst...");
                        itemChange.Name = Console.ReadLine().ToString();
                    }
                }
            }

            foreach (var x in toDoList)
            {
                Console.WriteLine(x);
            }
        }
예제 #8
0
        public void Complete(Guid ID)
        {
            ToDoItem todo = _list.Find(x => x.ID == ID);

            todo.Completed = true;
        }