Example #1
0
        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;
        }
Example #2
0
        public void Update(int id, Task item)
        {
            var foundItem = Context.Tasks.Where(t => t.Id == id).Single();

            if (foundItem != null)
            {
                foundItem.IsComplete = item.IsComplete;
                foundItem.Name = item.Name;
                foundItem.Priority = item.Priority;

                Context.SaveChanges();
            }
        }
Example #3
0
        public bool AddTask(Task task)
        {
            var foundTask = _repository.Get(task.Id);

            if (foundTask != null)
            {
                return false;
            }

            _repository.Add(task);

            return true;
        }
Example #4
0
        public bool UpdateTask(int id, Task task)
        {
            // ensure we have something to update

            var foundTask = _repository.Get(id);

            if (foundTask == null)
            {
                return false;
            }

            _repository.Update(id, task);
            return true;
        }
Example #5
0
 public void Add(Task item)
 {
     Context.Tasks.Add(item);
     Context.SaveChanges();
 }
Example #6
0
        public bool PutTask(int id, Task task)
        {
            var taskService = new TaskService();

            return taskService.UpdateTask(id, task);
        }