1
- namespace ServiceStack . Northwind . ServiceInterface
2
- {
3
- using System ;
4
- using System . Net ;
5
- using ServiceStack . Common . Web ;
6
- using ServiceStack . Northwind . ServiceModel . Operations ;
7
- using ServiceStack . Northwind . ServiceModel . Types ;
8
- using ServiceStack . OrmLite ;
9
- using ServiceStack . ServiceInterface ;
10
-
11
- public class CustomerDetailsService : Service
12
- {
13
- public IDbConnectionFactory DbFactory { get ; set ; }
1
+ using System ;
2
+ using System . Net ;
3
+ using ServiceStack . Common . Web ;
4
+ using ServiceStack . Northwind . ServiceModel . Operations ;
5
+ using ServiceStack . Northwind . ServiceModel . Types ;
6
+ using ServiceStack . OrmLite ;
7
+ using ServiceStack . ServiceInterface ;
14
8
15
- public CustomerDetailsResponse Get ( CustomerDetails request )
16
- {
17
- var customer = DbFactory . Run ( dbCmd => dbCmd . GetByIdOrDefault < Customer > ( request . Id ) ) ;
18
- if ( customer == null )
19
- throw new HttpError ( HttpStatusCode . NotFound ,
20
- new ArgumentException ( "Customer does not exist: " + request . Id ) ) ;
9
+ namespace ServiceStack . Northwind . ServiceInterface
10
+ {
11
+ public class CustomerDetailsService : Service
12
+ {
13
+ public CustomerDetailsResponse Get ( CustomerDetails request )
14
+ {
15
+ var customer = Db . GetByIdOrDefault < Customer > ( request . Id ) ;
16
+ if ( customer == null )
17
+ throw new HttpError ( HttpStatusCode . NotFound ,
18
+ new ArgumentException ( "Customer does not exist: " + request . Id ) ) ;
21
19
22
- var ordersService = base . ResolveService < OrdersService > ( ) ;
23
- var ordersResponse = ( OrdersResponse ) ordersService . Get ( new Orders { CustomerId = customer . Id } ) ;
20
+ var ordersService = base . ResolveService < OrdersService > ( ) ;
21
+ var ordersResponse = ( OrdersResponse ) ordersService . Get ( new Orders { CustomerId = customer . Id } ) ;
24
22
25
- return new CustomerDetailsResponse
26
- {
27
- Customer = customer ,
28
- CustomerOrders = ordersResponse . Results ,
29
- } ;
30
- }
31
- }
32
- }
23
+ return new CustomerDetailsResponse
24
+ {
25
+ Customer = customer ,
26
+ CustomerOrders = ordersResponse . Results ,
27
+ } ;
28
+ }
29
+ }
30
+ }
0 commit comments