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; }
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(); } }
public bool AddTask(Task task) { var foundTask = _repository.Get(task.Id); if (foundTask != null) { return false; } _repository.Add(task); return true; }
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; }
public void Add(Task item) { Context.Tasks.Add(item); Context.SaveChanges(); }
public bool PutTask(int id, Task task) { var taskService = new TaskService(); return taskService.UpdateTask(id, task); }