Skip to content

Commit 3949c1d

Browse files
committed
Minor Spelling/Grammar Corrections
On some, it looks like a bigger changes, but that is just because my IDE cleansed some of the intermix of tabs & spaces in the code layout.
1 parent 9503a88 commit 3949c1d

File tree

9 files changed

+895
-878
lines changed

9 files changed

+895
-878
lines changed
Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
1-
using ServiceStack.CacheAccess;
2-
using ServiceStack.Common;
3-
using ServiceStack.Northwind.ServiceModel.Operations;
4-
using ServiceStack.ServiceHost;
5-
using ServiceStack.ServiceInterface;
6-
7-
namespace ServiceStack.Northwind.ServiceInterface
8-
{
9-
/// <summary>
10-
/// Create your ServiceStack rest-ful web service implementation.
11-
/// </summary>
12-
public class CachedCustomersService : RestServiceBase<CachedCustomers>
13-
{
14-
/// <summary>
15-
/// Gets or sets the cache client. The built-in IoC used with ServiceStack autowires this property.
16-
/// </summary>
17-
public ICacheClient CacheClient { get; set; }
18-
19-
public override object OnGet(CachedCustomers request)
20-
{
21-
//Manually create the Unified Resource Name "urn:customers".
22-
return base.RequestContext.ToOptimizedResultUsingCache(
23-
this.CacheClient, "urn:customers", () =>
24-
{
25-
//Resolve the service in order to get the customers.
26-
var service = this.ResolveService<CustomersService>();
27-
return (CustomersResponse)service.Get(new Customers());
28-
});
29-
}
30-
}
31-
32-
/// <summary>
33-
/// Create your ServiceStack rest-ful web service implementation.
34-
/// </summary>
35-
public class CachedCustomerDetailsService : RestServiceBase<CachedCustomerDetails>
36-
{
37-
/// <summary>
38-
/// Gets or sets the cache client. The built-in IoC used with ServiceStack autowires this property.
39-
/// </summary>
40-
public ICacheClient CacheClient { get; set; }
41-
42-
public override object OnGet(CachedCustomerDetails request)
43-
{
44-
//Create the Unified Resource Name "urn:customerdetails:{id}".
45-
var cacheKey = UrnId.Create<CustomerDetails>(request.Id);
46-
return base.RequestContext.ToOptimizedResultUsingCache(
47-
this.CacheClient, cacheKey, () =>
48-
{
49-
return (CustomerDetailsResponse)this.ResolveService<CustomerDetailsService>()
50-
.Get(new CustomerDetails { Id = request.Id });
51-
});
52-
}
53-
}
54-
55-
/// <summary>
56-
/// Create your ServiceStack rest-ful web service implementation.
57-
/// </summary>
58-
public class CachedOrdersService : RestServiceBase<CachedOrders>
59-
{
60-
/// <summary>
61-
/// Gets or sets the cache client. The built-in IoC used with ServiceStack autowires this property.
62-
/// </summary>
63-
public ICacheClient CacheClient { get; set; }
64-
65-
public override object OnGet(CachedOrders request)
66-
{
67-
var cacheKey = UrnId.Create<Orders>(request.CustomerId ?? "all", request.Page.GetValueOrDefault(0).ToString());
68-
return base.RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey, () =>
69-
{
70-
return (OrdersResponse)this.ResolveService<OrdersService>()
71-
.Get(new Orders { CustomerId = request.CustomerId, Page = request.Page });
72-
});
73-
}
74-
}
75-
76-
}
1+
using ServiceStack.CacheAccess;
2+
using ServiceStack.Common;
3+
using ServiceStack.Northwind.ServiceModel.Operations;
4+
using ServiceStack.ServiceHost;
5+
using ServiceStack.ServiceInterface;
6+
7+
namespace ServiceStack.Northwind.ServiceInterface
8+
{
9+
/// <summary>
10+
/// Create your ServiceStack RESTful web service implementation.
11+
/// </summary>
12+
public class CachedCustomersService : RestServiceBase<CachedCustomers>
13+
{
14+
/// <summary>
15+
/// Gets or sets the cache client. The built-in IoC used with ServiceStack auto wires this property.
16+
/// </summary>
17+
public ICacheClient CacheClient { get; set; }
18+
19+
public override object OnGet(CachedCustomers request)
20+
{
21+
//Manually create the Unified Resource Name "urn:customers".
22+
return base.RequestContext.ToOptimizedResultUsingCache(
23+
this.CacheClient, "urn:customers", () =>
24+
{
25+
//Resolve the service in order to get the customers.
26+
var service = this.ResolveService<CustomersService>();
27+
return (CustomersResponse)service.Get(new Customers());
28+
});
29+
}
30+
}
31+
32+
/// <summary>
33+
/// Create your ServiceStack RESTful web service implementation.
34+
/// </summary>
35+
public class CachedCustomerDetailsService : RestServiceBase<CachedCustomerDetails>
36+
{
37+
/// <summary>
38+
/// Gets or sets the cache client. The built-in IoC used with ServiceStack auto wires this property.
39+
/// </summary>
40+
public ICacheClient CacheClient { get; set; }
41+
42+
public override object OnGet(CachedCustomerDetails request)
43+
{
44+
//Create the Unified Resource Name "urn:customerdetails:{id}".
45+
var cacheKey = UrnId.Create<CustomerDetails>(request.Id);
46+
return base.RequestContext.ToOptimizedResultUsingCache(
47+
this.CacheClient, cacheKey, () =>
48+
{
49+
return (CustomerDetailsResponse)this.ResolveService<CustomerDetailsService>()
50+
.Get(new CustomerDetails { Id = request.Id });
51+
});
52+
}
53+
}
54+
55+
/// <summary>
56+
/// Create your ServiceStack RESTful web service implementation.
57+
/// </summary>
58+
public class CachedOrdersService : RestServiceBase<CachedOrders>
59+
{
60+
/// <summary>
61+
/// Gets or sets the cache client. The built-in IoC used with ServiceStack auto wires this property.
62+
/// </summary>
63+
public ICacheClient CacheClient { get; set; }
64+
65+
public override object OnGet(CachedOrders request)
66+
{
67+
var cacheKey = UrnId.Create<Orders>(request.CustomerId ?? "all", request.Page.GetValueOrDefault(0).ToString());
68+
return base.RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey, () =>
69+
{
70+
return (OrdersResponse)this.ResolveService<OrdersService>()
71+
.Get(new Orders { CustomerId = request.CustomerId, Page = request.Page });
72+
});
73+
}
74+
}
75+
76+
}
Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
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;
8-
9-
namespace ServiceStack.Northwind.ServiceInterface
10-
{
11-
/// <summary>
12-
/// Create your ServiceStack rest-ful web service implementation.
13-
/// </summary>
14-
public class CustomerDetailsService : RestServiceBase<CustomerDetails>
15-
{
16-
/// <summary>
17-
/// Gets or sets the database factory. The built-in IoC used with ServiceStack autowires this property.
18-
/// </summary>
19-
public IDbConnectionFactory DbFactory { get; set; }
20-
21-
public override object OnGet(CustomerDetails request)
22-
{
23-
var customer = DbFactory.Run(dbCmd => dbCmd.GetByIdOrDefault<Customer>(request.Id));
24-
if (customer == null)
25-
throw new HttpError(HttpStatusCode.NotFound,
26-
new ArgumentException("Customer does not exist: " + request.Id));
27-
28-
var ordersService = base.ResolveService<OrdersService>();
29-
var ordersResponse = (OrdersResponse)ordersService.Get(new Orders { CustomerId = customer.Id });
30-
31-
return new CustomerDetailsResponse
32-
{
33-
Customer = customer,
34-
CustomerOrders = ordersResponse.Results,
35-
};
36-
}
37-
}
38-
}
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;
8+
9+
namespace ServiceStack.Northwind.ServiceInterface
10+
{
11+
/// <summary>
12+
/// Create your ServiceStack RESTful web service implementation.
13+
/// </summary>
14+
public class CustomerDetailsService : RestServiceBase<CustomerDetails>
15+
{
16+
/// <summary>
17+
/// Gets or sets the database factory. The built-in IoC used with ServiceStack auto wires this property.
18+
/// </summary>
19+
public IDbConnectionFactory DbFactory { get; set; }
20+
21+
public override object OnGet(CustomerDetails request)
22+
{
23+
var customer = DbFactory.Run(dbCmd => dbCmd.GetByIdOrDefault<Customer>(request.Id));
24+
if (customer == null)
25+
throw new HttpError(HttpStatusCode.NotFound,
26+
new ArgumentException("Customer does not exist: " + request.Id));
27+
28+
var ordersService = base.ResolveService<OrdersService>();
29+
var ordersResponse = (OrdersResponse)ordersService.Get(new Orders { CustomerId = customer.Id });
30+
31+
return new CustomerDetailsResponse
32+
{
33+
Customer = customer,
34+
CustomerOrders = ordersResponse.Results,
35+
};
36+
}
37+
}
38+
}
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
using ServiceStack.Northwind.ServiceModel.Operations;
2-
using ServiceStack.Northwind.ServiceModel.Types;
3-
using ServiceStack.OrmLite;
4-
using ServiceStack.ServiceInterface;
5-
6-
namespace ServiceStack.Northwind.ServiceInterface
7-
{
8-
/// <summary>
9-
/// Create your ServiceStack rest-ful web service implementation.
10-
/// </summary>
11-
public class CustomersService : RestServiceBase<Customers>
12-
{
13-
/// <summary>
14-
/// Gets or sets the database factory. The built-in IoC used with ServiceStack autowires this property.
15-
/// </summary>
16-
public IDbConnectionFactory DbFactory { get; set; }
17-
18-
public override object OnGet(Customers request)
19-
{
20-
return new CustomersResponse { Customers = DbFactory.Run(dbCmd => dbCmd.Select<Customer>()) };
21-
}
22-
}
23-
}
1+
using ServiceStack.Northwind.ServiceModel.Operations;
2+
using ServiceStack.Northwind.ServiceModel.Types;
3+
using ServiceStack.OrmLite;
4+
using ServiceStack.ServiceInterface;
5+
6+
namespace ServiceStack.Northwind.ServiceInterface
7+
{
8+
/// <summary>
9+
/// Create your ServiceStack RESTful web service implementation.
10+
/// </summary>
11+
public class CustomersService : RestServiceBase<Customers>
12+
{
13+
/// <summary>
14+
/// Gets or sets the database factory. The built-in IoC used with ServiceStack auto wires this property.
15+
/// </summary>
16+
public IDbConnectionFactory DbFactory { get; set; }
17+
18+
public override object OnGet(Customers request)
19+
{
20+
return new CustomersResponse { Customers = DbFactory.Run(dbCmd => dbCmd.Select<Customer>()) };
21+
}
22+
}
23+
}
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
using System.Linq;
2-
using ServiceStack.Common.Extensions;
3-
using ServiceStack.Northwind.ServiceModel.Operations;
4-
using ServiceStack.Northwind.ServiceModel.Types;
5-
using ServiceStack.OrmLite;
6-
using ServiceStack.ServiceInterface;
7-
8-
namespace ServiceStack.Northwind.ServiceInterface
9-
{
10-
/// <summary>
11-
/// Create your ServiceStack rest-ful web service implementation.
12-
/// </summary>
13-
public class OrdersService : RestServiceBase<Orders>
14-
{
15-
private const int PageCount = 20;
16-
17-
/// <summary>
18-
/// Gets or sets the database factory. The built-in IoC used with ServiceStack autowires this property.
19-
/// </summary>
20-
public IDbConnectionFactory DbFactory { get; set; }
21-
22-
public override object OnGet(Orders request)
23-
{
24-
using (var dbConn = DbFactory.OpenDbConnection())
25-
{
26-
var orders = request.CustomerId.IsNullOrEmpty()
27-
? dbConn.Select<Order>("ORDER BY OrderDate DESC LIMIT {0}, {1}", (request.Page.GetValueOrDefault(1) - 1) * PageCount, PageCount)
28-
: dbConn.Select<Order>("CustomerId = {0}", request.CustomerId);
29-
30-
if (orders.Count == 0) { return new OrdersResponse(); }
31-
32-
var orderDetails = dbConn.Select<OrderDetail>(
33-
"OrderId IN ({0})", new SqlInValues(orders.ConvertAll(x => x.Id)));
34-
35-
var orderDetailsLookup = orderDetails.ToLookup(o => o.OrderId);
36-
37-
var customerOrders = orders.ConvertAll(o =>
38-
new CustomerOrder
39-
{
40-
Order = o,
41-
OrderDetails = orderDetailsLookup[o.Id].ToList()
42-
});
43-
44-
return new OrdersResponse { Results = customerOrders };
45-
}
46-
}
47-
}
48-
}
1+
using System.Linq;
2+
using ServiceStack.Common.Extensions;
3+
using ServiceStack.Northwind.ServiceModel.Operations;
4+
using ServiceStack.Northwind.ServiceModel.Types;
5+
using ServiceStack.OrmLite;
6+
using ServiceStack.ServiceInterface;
7+
8+
namespace ServiceStack.Northwind.ServiceInterface
9+
{
10+
/// <summary>
11+
/// Create your ServiceStack RESTful web service implementation.
12+
/// </summary>
13+
public class OrdersService : RestServiceBase<Orders>
14+
{
15+
private const int PageCount = 20;
16+
17+
/// <summary>
18+
/// Gets or sets the database factory. The built-in IoC used with ServiceStack auto wires this property.
19+
/// </summary>
20+
public IDbConnectionFactory DbFactory { get; set; }
21+
22+
public override object OnGet(Orders request)
23+
{
24+
using (var dbConn = DbFactory.OpenDbConnection())
25+
{
26+
var orders = request.CustomerId.IsNullOrEmpty()
27+
? dbConn.Select<Order>("ORDER BY OrderDate DESC LIMIT {0}, {1}", (request.Page.GetValueOrDefault(1) - 1) * PageCount, PageCount)
28+
: dbConn.Select<Order>("CustomerId = {0}", request.CustomerId);
29+
30+
if (orders.Count == 0) { return new OrdersResponse(); }
31+
32+
var orderDetails = dbConn.Select<OrderDetail>(
33+
"OrderId IN ({0})", new SqlInValues(orders.ConvertAll(x => x.Id)));
34+
35+
var orderDetailsLookup = orderDetails.ToLookup(o => o.OrderId);
36+
37+
var customerOrders = orders.ConvertAll(o =>
38+
new CustomerOrder
39+
{
40+
Order = o,
41+
OrderDetails = orderDetailsLookup[o.Id].ToList()
42+
});
43+
44+
return new OrdersResponse { Results = customerOrders };
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)