/// <summary> /// Move a Task from his containing List to another List. /// </summary> /// <param name="task">Task to be moved</param> /// <param name="destinationList">List to be the moved Task container</param> /// <returns>The new row key from the moved Task</returns> public string Move(Task task, List destinationList) { return _notesService.MoveNote(task.MapToNote(), destinationList.MapToTaskList()); }
public Task Move(string userId, string resourceId, [FromBody] string destinationListPartitionKey, [FromBody] string destinationListRowKey) { var task = _tasksService.Get(userId, resourceId); if (task == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var list = _listsService.Get(destinationListPartitionKey, destinationListRowKey); if (list == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var movedTaskRowKey = _tasksService.Move(task, list); var movedTask = new Task(task.PartitionKey, movedTaskRowKey, task.Title, task.Content, task.IsClosed); var uri = Url.Route("WebAPI", new { controller = "Tasks", action = "Details", userId, movedTask.RowKey }); var absoluteUrl = new Uri(Request.RequestUri, uri).AbsoluteUri; var selfLink = new Link { Name = "self", Rel = "http://api.relations.wrml.org/common/self", Href = absoluteUrl }; uri = Url.Route("WebAPI", new { controller = "Tasks", action = "All", userId }); absoluteUrl = new Uri(Request.RequestUri, uri).AbsoluteUri; var allLink = new Link { Name = "self", Rel = "http://api.relations.wrml.org/common/all", Href = absoluteUrl }; uri = Url.Route("WebAPI", new { controller = "Lists", action = "Details", list.PartitionKey, list.RowKey }); absoluteUrl = new Uri(Request.RequestUri, uri).AbsoluteUri; var parentLink = new Link { Name = "self", Rel = "http://api.relations.wrml.org/common/parent", Href = absoluteUrl }; movedTask.Links.Add(selfLink); movedTask.Links.Add(allLink); movedTask.Links.Add(parentLink); return movedTask; }