Skip to content

Commit 2fd326f

Browse files
committed
Update CustomerDetailsService.cs
1 parent 5075428 commit 2fd326f

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed
Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
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;
148

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));
2119

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});
2422

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

Comments
 (0)