Exemple #1
0
        private static void AddDefaultTasks()
        {
            Console.WriteLine("Adding default tasks...");

            var taskService = new TaskService();
            taskService.AddTask(new Task ("New Task", Priority.None));
            taskService.AddTask(new Task ("New Task 2", Priority.None));

            Console.WriteLine("Tasks Added");
            Console.ReadLine();
        }
        public HttpResponseMessage PostTask(Task task)
        {
            var taskService = new TaskService();

            taskService.AddTask(task);

            // Build a response that contains the location of the new movie
            var response = new HttpResponseMessage(HttpStatusCode.Created);
            var relativePath = "/api/Task/" + task.Id;
            response.Headers.Location = new Uri(Request.RequestUri, relativePath);
            return response;
        }
Exemple #3
0
        private static void DeleteTasks()
        {
            Console.WriteLine("Deleting tasks...");

            var taskService = new TaskService();

            var allTasks = taskService.GetTasks();

            allTasks.Select(t => taskService.RemoveTask(t.Id));

            Console.WriteLine("Tasks Deleted");
            Console.ReadLine();
        }
        public bool PutTask(int id, Task task)
        {
            var taskService = new TaskService();

            return taskService.UpdateTask(id, task);
        }
        public IEnumerable<Task> GetAllTasks()
        {
            var taskService = new TaskService();

            return taskService.GetTasks();
        }
        public bool DeleteTask(int id)
        {
            var taskService = new TaskService();

            return taskService.RemoveTask(id);
        }