示例#1
0
        public IHttpActionResult PutToDoList(int id, ToDoListApp.ToDoList toDoList)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != toDoList.Id)
            {
                return(BadRequest());
            }

            db.Entry(toDoList).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ToDoListExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        static void Main(string[] args)
        {
            ToDoList list = new ToDoList();

            while (true)
            {
                Console.WriteLine("Lūdzu izvēlieties darbību:");
                Console.WriteLine("a - pievienot");
                Console.WriteLine("p - parādīt");
                Console.WriteLine("d - Dzēst");
                Console.WriteLine("g - Dzēst visu sarakstu");
                string userinput = Console.ReadLine();
                switch (userinput)
                {
                case "a":
                    // Pievienot jaunu darāmo lietu
                    Console.WriteLine("ludzu ievadiet darāmo lietu:");
                    string todoTask = Console.ReadLine();
                    list.AddNewTodo(todoTask);
                    break;

                case "p":
                    //izvadat visas darāmas lietas uz ekrana
                    list.ShowAllTodos();
                    break;

                case "d":
                    //dzēst konkrētu darāmo lietu
                    Console.WriteLine("lūdzu ievadi dzēšamo nummuru");
                    list.ShowAllTodos();
                    int index = int.Parse(Console.ReadLine());
                    list.deliteTodo(index - 1);
                    break;

                // pievienot funkciju kas notira visu sarakstu
                case "g":

                    list.DeldeliteTodo();
                    break;

                case "s":
                    //Saglabajam saturu failā
                    list.SaveToFile();
                    break;

                //implementejam ieladi no faila izmantojot funkciju
                //File.ReadAlllines(path);
                case "l":
                    list.LoadFromeFile();
                    break;
                }
                // Pievienot jaunu darāmo lietu
                // Es gribu dzēst visas daramas lietas
                // izvadīt visas darāmās lietas uz ekrāna
            }
        }
示例#3
0
        public IHttpActionResult GetToDoList(int id)
        {
            ToDoListApp.ToDoList toDoList = db.ToDoLists.Find(id);
            if (toDoList == null)
            {
                return(NotFound());
            }

            return(Ok(toDoList));
        }
示例#4
0
        public IHttpActionResult PostToDoList(ToDoListApp.ToDoList toDoList)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ToDoLists.Add(toDoList);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = toDoList.Id }, toDoList));
        }
示例#5
0
        public IHttpActionResult DeleteToDoList(int id)
        {
            ToDoListApp.ToDoList toDoList = db.ToDoLists.Find(id);
            if (toDoList == null)
            {
                return(NotFound());
            }

            db.ToDoLists.Remove(toDoList);
            db.SaveChanges();

            return(Ok(toDoList));
        }
示例#6
0
        static void Main(string[] args)
        {
            ToDoList list = new ToDoList();

            while (true)
            {
                Console.WriteLine("Add thing to do:");
                string todoTask = Console.ReadLine();
                list.AddNewTodo(todoTask);
                list.ShowAllTodos();

                // Console.WriteLine("b - Add things to do");
            }
        }
示例#7
0
        private void BtnShowItems_Click(object sender, RoutedEventArgs e)
        {
            ToDoList toDoList = (ToDoList)dtgToDoLists?.SelectedItem;

            if (toDoList == null)
            {
                MessageBox.Show("Please select a to-do list!");
            }
            else
            {
                ToDoListItems toDoListItems = new ToDoListItems(toDoList.Id, userId);
                toDoListItems.ShowDialog();
            }
        }
示例#8
0
 private void BtnDeleteList_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ToDoList toDoList = (ToDoList)dtgToDoLists.SelectedItem;
         if (MessageBox.Show("Are you sure?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             _toDoListRepsitory.Delete(toDoList);
             GetDataGridList();
             MessageBox.Show("List deleted!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#9
0
        private static void Item_CRUD(int userAnswer, ToDoList todolist, User myUser, List <ItemDetails> toDoListItems)
        {
            int itemNum;

            switch (userAnswer)
            {
            case 1:     // add
                AddingItems(todolist);
                break;


            case 2:     // view
                Console.Write("Press the item number: ");
                int.TryParse(Console.ReadLine(), out itemNum);

                Console.WriteLine("Item Details: Descripton:", toDoListItems[itemNum - 1].Description);
                break;

            case 3:     // update
                Console.Write("Press the item number: ");
                int.TryParse(Console.ReadLine(), out itemNum);

                Console.Write("/nDo you want to update the item name? y/n ==> ");
                if (Console.ReadLine() == "y" || Console.ReadLine() == "Y")
                {
                    Console.Write("Update item name: ");
                    toDoListItems[itemNum - 1].Name = Console.ReadLine();
                }
                Console.Write("Update item description: ");
                toDoListItems[itemNum].Description = Console.ReadLine();

                itemDetailsService.Update(toDoListItems[itemNum - 1].Name, toDoListItems[itemNum - 1]);
                break;

            case 4:     // delete
                Console.Write("Press the item number: ");
                int.TryParse(Console.ReadLine(), out itemNum);
                itemDetailsService.DeletingProcess(toDoListItems[itemNum - 1]);
                todolist.ItemsIds.Remove(toDoListItems[itemNum - 1].Refnum);
                break;

            default:
                break;
            }
        }
示例#10
0
 private void BtnNewList_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var newList = new ToDoList
         {
             Name   = txtNewList.Text,
             UserId = userId
         };
         _toDoListRepsitory.Add(newList);
         MessageBox.Show("New list added!");
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#11
0
        static void Main(string[] args)
        {
            ToDoList list = new ToDoList();


            while (true)
            {
                Console.WriteLine("Lūdzu izvēlieties darbību:");
                Console.WriteLine("a - pievienot");
                Console.WriteLine("p - parādīt");
                Console.WriteLine("d - dzēst");
                Console.WriteLine("at - izdarīts");
                Console.WriteLine("c - dzēst visu");
                Console.WriteLine("s - saglabāt");
                Console.WriteLine("l - ielādēt");
                string usersInput = Console.ReadLine();
                switch (usersInput)
                {
                case "pievienot":
                case "a":
                    Console.WriteLine("Lūdzu ievadiet darāmo lietu skaitu:");
                    string toDoTask = Console.ReadLine();
                    list.AddNewToDo(toDoTask);
                    break;

                case "print":
                case "p":
                    list.ShowAllToDos();
                    break;

                case "at":
                    Console.WriteLine("Lūdzu ievadi pabeigtā uzdevuma numuru.");
                    list.ShowAllToDos();
                    int doneToDoIndex = int.Parse(Console.ReadLine());
                    list.MarkTodoAsDone(doneToDoIndex - 1);
                    break;

                case "d":
                    Console.WriteLine("Lūdzu ievadi dzēšamo numuru");
                    list.ShowAllToDos();
                    int index = int.Parse(Console.ReadLine());
                    list.deleteToDo(index - 1);
                    break;

                case "c":
                    Console.WriteLine("Vai vēlies izdzēst visu sarakstu? jā/nē");
                    list.deleteAllToDos();
                    break;

                case "s":
                    list.SaveToFile();
                    break;

                case "l":
                    list.LoadFromFile();
                    break;

                default:
                    Console.WriteLine("Neatpazina komandu!");
                    break;
                }
            }
        }