88//The entire C# source code for the ServiceStack + Redis TODO REST backend. There is no other .cs :)
99namespace Backbone . Todos
1010{
11- /// <summary>
12- /// Define your ServiceStack web service request (i.e. Request DTO).
13- /// </summary>
11+ // Define your ServiceStack web service request (i.e. Request DTO).
1412 public class Todo
1513 {
1614 public long Id { get ; set ; }
@@ -19,9 +17,7 @@ public class Todo
1917 public bool Done { get ; set ; }
2018 }
2119
22- /// <summary>
23- /// Create your ServiceStack rest-ful web service implementation.
24- /// </summary>
20+ // Create your ServiceStack rest-ful web service implementation.
2521 public class TodoService : Service
2622 {
2723 public object Get ( Todo todo )
@@ -34,9 +30,7 @@ public object Get(Todo todo)
3430 return Redis . As < Todo > ( ) . GetAll ( ) ;
3531 }
3632
37- /// <summary>
38- /// Handles creating and updating the Todo items.
39- /// </summary>
33+ // Handles creating and updating the Todo items.
4034 public Todo Post ( Todo todo )
4135 {
4236 var redis = Redis . As < Todo > ( ) ;
@@ -50,37 +44,26 @@ public Todo Post(Todo todo)
5044 return todo ;
5145 }
5246
53- /// <summary>
54- /// Handles creating and updating the Todo items.
55- /// </summary>
47+ // Handles creating and updating the Todo items.
5648 public Todo Put ( Todo todo )
5749 {
5850 return Post ( todo ) ;
5951 }
6052
61- /// <summary>
62- /// Handles Deleting the Todo item
63- /// </summary>
53+ // Handles Deleting the Todo item
6454 public void Delete ( Todo todo )
6555 {
6656 Redis . As < Todo > ( ) . DeleteById ( todo . Id ) ;
6757 }
6858 }
6959
70- /// <summary>
71- /// Create your ServiceStack web service application with a singleton AppHost.
72- /// </summary>
60+ // Create your ServiceStack web service application with a singleton AppHost.
7361 public class ToDoAppHost : AppHostBase
7462 {
75- /// <summary>
76- /// Initializes a new instance of your ServiceStack application, with the specified name and assembly containing the services.
77- /// </summary>
63+ // Initializes a new instance of your ServiceStack application, with the specified name and assembly containing the services.
7864 public ToDoAppHost ( ) : base ( "Backbone.js TODO" , typeof ( TodoService ) . Assembly ) { }
7965
80- /// <summary>
81- /// Configure the container with the necessary routes for your ServiceStack application.
82- /// </summary>
83- /// <param name="container">The built-in IoC used with ServiceStack.</param>
66+ // Configure the container with the necessary routes for your ServiceStack application.
8467 public override void Configure ( Container container )
8568 {
8669 //Configure ServiceStack Json web services to return idiomatic Json camelCase properties.
@@ -89,7 +72,7 @@ public override void Configure(Container container)
8972 //Register Redis factory in Funq IoC. The default port for Redis is 6379.
9073 container . Register < IRedisClientsManager > ( new BasicRedisClientManager ( "localhost:6379" ) ) ;
9174
92- //Register user-defined REST Paths
75+ //Register user-defined REST Paths using the fluent configuration API
9376 Routes
9477 . Add < Todo > ( "/todos" )
9578 . Add < Todo > ( "/todos/{Id}" ) ;
@@ -100,8 +83,8 @@ public class Global : System.Web.HttpApplication
10083 {
10184 protected void Application_Start ( object sender , EventArgs e )
10285 {
103- //Initialize your application
86+ //Initialize your ServiceStack AppHost
10487 ( new ToDoAppHost ( ) ) . Init ( ) ;
10588 }
10689 }
107- }
90+ }
0 commit comments