コード例 #1
0
        public object Get(Todo todo)
        {
            //Return a single Todo if the id is provided.
            if (todo.Id != default(long))
                return Redis.As<Todo>().GetById(todo.Id);

            //Return all Todos items.
            return Redis.As<Todo>().GetAll();
        }
コード例 #2
0
 /// <summary>
 /// Handles creating and updating the Todo items.
 /// </summary>
 /// <param name="todo">The todo.</param>
 /// <returns></returns>
 public Todo Post(Todo todo)
 {
     RedisManager.ExecAs<Todo>(r =>
     {
         //Get next id for new todo
         if (todo.Id == default(long)) todo.Id = r.GetNextSequence();
         r.Store(todo);
     });
     return todo;
 }
コード例 #3
0
        public object Get(Todo todo)
        {
            //Return a single Todo if the id is provided.
            if (todo.Id != default(long))
            {
                return RedisManager.ExecAs<Todo>(r => r.GetById(todo.Id));
            }

            //Return all Todos items.
            return RedisManager.ExecAs<Todo>(r => r.GetAll());
        }
コード例 #4
0
 /// <summary>
 /// Handles creating and updating the Todo items.
 /// </summary>
 public Todo Post(Todo todo)
 {
     var redis = Redis.As<Todo>();
     
     //Get next id for new todo
     if (todo.Id == default(long)) 
         todo.Id = redis.GetNextSequence();
     
     redis.Store(todo);
     
     return todo;
 }
コード例 #5
0
 public object Delete(Todo todo)
 {
     RedisManager.ExecAs<Todo>(r => r.DeleteById(todo.Id));
     return null;
 }
コード例 #6
0
 /// <summary>
 /// Handles creating and updating the Todo items.
 /// </summary>
 /// <param name="todo">The todo.</param>
 /// <returns></returns>
 public Todo Put(Todo todo)
 {
     return Post(todo);
 }
コード例 #7
0
 /// <summary>
 /// Handles Deleting the Todo item
 /// </summary>
 public void Delete(Todo todo)
 {
     Redis.As<Todo>().DeleteById(todo.Id);
 }