8
8
//The entire C# source code for the ServiceStack + Redis TODO REST backend. There is no other .cs :)
9
9
namespace Backbone . Todos
10
10
{
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).
14
12
public class Todo
15
13
{
16
14
public long Id { get ; set ; }
@@ -19,9 +17,7 @@ public class Todo
19
17
public bool Done { get ; set ; }
20
18
}
21
19
22
- /// <summary>
23
- /// Create your ServiceStack rest-ful web service implementation.
24
- /// </summary>
20
+ // Create your ServiceStack rest-ful web service implementation.
25
21
public class TodoService : Service
26
22
{
27
23
public object Get ( Todo todo )
@@ -34,9 +30,7 @@ public object Get(Todo todo)
34
30
return Redis . As < Todo > ( ) . GetAll ( ) ;
35
31
}
36
32
37
- /// <summary>
38
- /// Handles creating and updating the Todo items.
39
- /// </summary>
33
+ // Handles creating and updating the Todo items.
40
34
public Todo Post ( Todo todo )
41
35
{
42
36
var redis = Redis . As < Todo > ( ) ;
@@ -50,37 +44,26 @@ public Todo Post(Todo todo)
50
44
return todo ;
51
45
}
52
46
53
- /// <summary>
54
- /// Handles creating and updating the Todo items.
55
- /// </summary>
47
+ // Handles creating and updating the Todo items.
56
48
public Todo Put ( Todo todo )
57
49
{
58
50
return Post ( todo ) ;
59
51
}
60
52
61
- /// <summary>
62
- /// Handles Deleting the Todo item
63
- /// </summary>
53
+ // Handles Deleting the Todo item
64
54
public void Delete ( Todo todo )
65
55
{
66
56
Redis . As < Todo > ( ) . DeleteById ( todo . Id ) ;
67
57
}
68
58
}
69
59
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.
73
61
public class ToDoAppHost : AppHostBase
74
62
{
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.
78
64
public ToDoAppHost ( ) : base ( "Backbone.js TODO" , typeof ( TodoService ) . Assembly ) { }
79
65
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.
84
67
public override void Configure ( Container container )
85
68
{
86
69
//Configure ServiceStack Json web services to return idiomatic Json camelCase properties.
@@ -89,7 +72,7 @@ public override void Configure(Container container)
89
72
//Register Redis factory in Funq IoC. The default port for Redis is 6379.
90
73
container . Register < IRedisClientsManager > ( new BasicRedisClientManager ( "localhost:6379" ) ) ;
91
74
92
- //Register user-defined REST Paths
75
+ //Register user-defined REST Paths using the fluent configuration API
93
76
Routes
94
77
. Add < Todo > ( "/todos" )
95
78
. Add < Todo > ( "/todos/{Id}" ) ;
@@ -100,8 +83,8 @@ public class Global : System.Web.HttpApplication
100
83
{
101
84
protected void Application_Start ( object sender , EventArgs e )
102
85
{
103
- //Initialize your application
86
+ //Initialize your ServiceStack AppHost
104
87
( new ToDoAppHost ( ) ) . Init ( ) ;
105
88
}
106
89
}
107
- }
90
+ }
0 commit comments