public List Details(string userId, string resourceId) { var list = _listsService.Get(userId, resourceId); if (list == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var uri = Url.Route("WebAPI", new { controller = "Lists", action = "Details", userId, resourceId }); 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 = "Lists", 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 }; list.Links.Add(selfLink); list.Links.Add(allLink); return list; }
public IEnumerable<List> All(string userId) { var lists = _listsService.GetAll(userId).ToList(); for (int i = 0; i < lists.Count; i++) { var uri = Url.Route("WebAPI", new { controller = "Lists", action = "Details", userId = lists[i].PartitionKey, resourceId = lists[i].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 }; lists[i].Links.Add(selfLink); } return lists; }
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; }