Created
September 22, 2015 23:11
-
-
Save AdamAndersonFalafelSoftware/76c826c7a14565c5cc25 to your computer and use it in GitHub Desktop.
Sample TableController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TodoItemController : TableController<TodoItem> | |
{ | |
protected override void Initialize(HttpControllerContext controllerContext) | |
{ | |
base.Initialize(controllerContext); | |
MobileServiceContext context = new MobileServiceContext(); | |
DomainManager = new EntityDomainManager<TodoItem>(context, Request, Services); | |
} | |
// GET tables/TodoItem | |
public IQueryable<TodoItem> GetAllTodoItems() | |
{ | |
return Query(); | |
} | |
// GET tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959 | |
public SingleResult<TodoItem> GetTodoItem(string id) | |
{ | |
return Lookup(id); | |
} | |
// PATCH tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959 | |
public Task<TodoItem> PatchTodoItem(string id, Delta<TodoItem> patch) | |
{ | |
return UpdateAsync(id, patch); | |
} | |
// POST tables/TodoItem | |
public async Task<IHttpActionResult> PostTodoItem(TodoItem item) | |
{ | |
TodoItem current = await InsertAsync(item); | |
return CreatedAtRoute("Tables", new { id = current.Id }, current); | |
} | |
// DELETE tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959 | |
public Task DeleteTodoItem(string id) | |
{ | |
return DeleteAsync(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment