Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (39 sloc) 980 Bytes
using ServiceStack;
using ServiceStack.Aws.DynamoDb;
using ServiceStack.DataAnnotations;
namespace Todos
{
[Route("/todos")]
[Route("/todos/{Id}")]
public class Todo
{
[AutoIncrement]
public long Id { get; set; }
public string Content { get; set; }
public int Order { get; set; }
public bool Done { get; set; }
}
public class TodoService : Service
{
public IPocoDynamo Dynamo { get; set; }
public object Get(Todo todo)
{
if (todo.Id != default(long))
return Dynamo.GetItem<Todo>(todo.Id);
return Dynamo.GetAll<Todo>();
}
public Todo Post(Todo todo)
{
Dynamo.PutItem(todo);
return todo;
}
public Todo Put(Todo todo)
{
return Post(todo);
}
public void Delete(Todo todo)
{
Dynamo.DeleteItem<Todo>(todo.Id);
}
}
}