Permalink
Browse files

Update Northwind to latest SS

  • Loading branch information...
1 parent d7b06d6 commit 5c2dc4319edec33376c5c9b76064dbab327adc5d @mythz mythz committed Dec 12, 2012
Showing with 398 additions and 946 deletions.
  1. +49 −76 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceInterface/CachedServices.cs
  2. +32 −37 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceInterface/CustomerDetailsService.cs
  3. +17 −23 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceInterface/CustomersService.cs
  4. +38 −48 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceInterface/OrdersService.cs
  5. +8 −11 ....Northwind/ServiceStack.Northwind.ServiceInterface/ServiceStack.Northwind.ServiceInterface.csproj
  6. +5 −0 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceInterface/packages.config
  7. +0 −1 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/Operations/CachedOperations.cs
  8. +0 −22 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/Operations/Customer.cs
  9. +0 −1 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/Operations/CustomerDetails.cs
  10. +0 −180 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/Operations/CustomerOperations.cs
  11. +0 −322 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/Operations/CustomerTypes.cs
  12. +1 −2 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/Operations/Customers.cs
  13. +1 −1 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/Operations/Orders.cs
  14. +8 −11 ...iceStack.Northwind/ServiceStack.Northwind.ServiceModel/ServiceStack.Northwind.ServiceModel.csproj
  15. +5 −0 src/ServiceStack.Northwind/ServiceStack.Northwind.ServiceModel/packages.config
  16. +51 −52 src/ServiceStack.Northwind/ServiceStack.Northwind/Global.asax.cs
  17. +162 −159 src/ServiceStack.Northwind/ServiceStack.Northwind/ServiceStack.Northwind.csproj
  18. BIN src/ServiceStack.Northwind/ServiceStack.Northwind/sqlite/x64/sqlite3.dll
  19. BIN src/ServiceStack.Northwind/ServiceStack.Northwind/sqlite/x86/sqlite3.dll
  20. BIN ...ceStack.Northwind/packages/ServiceStack.OrmLite.Sqlite.Mono.3.9.32/Content/sqlite/x64/sqlite3.dll
  21. BIN ...ceStack.Northwind/packages/ServiceStack.OrmLite.Sqlite.Mono.3.9.32/Content/sqlite/x86/sqlite3.dll
  22. BIN ...nd/packages/ServiceStack.OrmLite.Sqlite.Mono.3.9.32/ServiceStack.OrmLite.Sqlite.Mono.3.9.32.nupkg
  23. +21 −0 ...d/packages/ServiceStack.OrmLite.Sqlite.Mono.3.9.32/ServiceStack.OrmLite.Sqlite.Mono.3.9.32.nuspec
  24. BIN ...ceStack.Northwind/packages/ServiceStack.OrmLite.Sqlite.Mono.3.9.32/lib/net35/Mono.Data.Sqlite.dll
  25. BIN ...thwind/packages/ServiceStack.OrmLite.Sqlite.Mono.3.9.32/lib/net35/ServiceStack.OrmLite.Sqlite.dll
  26. BIN ...ack.Northwind/packages/ServiceStack.OrmLite.Sqlite.Mono.3.9.32/lib/net35/ServiceStack.OrmLite.dll
@@ -1,76 +1,49 @@
-using ServiceStack.CacheAccess;
-using ServiceStack.Common;
-using ServiceStack.Northwind.ServiceModel.Operations;
-using ServiceStack.ServiceHost;
-using ServiceStack.ServiceInterface;
-
-namespace ServiceStack.Northwind.ServiceInterface
-{
- /// <summary>
- /// Create your ServiceStack RESTful web service implementation.
- /// </summary>
- public class CachedCustomersService : RestServiceBase<CachedCustomers>
- {
- /// <summary>
- /// Gets or sets the cache client. The built-in IoC used with ServiceStack auto wires this property.
- /// </summary>
- public ICacheClient CacheClient { get; set; }
-
- public override object OnGet(CachedCustomers request)
- {
- //Manually create the Unified Resource Name "urn:customers".
- return base.RequestContext.ToOptimizedResultUsingCache(
- this.CacheClient, "urn:customers", () =>
- {
- //Resolve the service in order to get the customers.
- var service = this.ResolveService<CustomersService>();
- return (CustomersResponse)service.Get(new Customers());
- });
- }
- }
-
- /// <summary>
- /// Create your ServiceStack RESTful web service implementation.
- /// </summary>
- public class CachedCustomerDetailsService : RestServiceBase<CachedCustomerDetails>
- {
- /// <summary>
- /// Gets or sets the cache client. The built-in IoC used with ServiceStack auto wires this property.
- /// </summary>
- public ICacheClient CacheClient { get; set; }
-
- public override object OnGet(CachedCustomerDetails request)
- {
- //Create the Unified Resource Name "urn:customerdetails:{id}".
- var cacheKey = UrnId.Create<CustomerDetails>(request.Id);
- return base.RequestContext.ToOptimizedResultUsingCache(
- this.CacheClient, cacheKey, () =>
- {
- return (CustomerDetailsResponse)this.ResolveService<CustomerDetailsService>()
- .Get(new CustomerDetails { Id = request.Id });
- });
- }
- }
-
- /// <summary>
- /// Create your ServiceStack RESTful web service implementation.
- /// </summary>
- public class CachedOrdersService : RestServiceBase<CachedOrders>
- {
- /// <summary>
- /// Gets or sets the cache client. The built-in IoC used with ServiceStack auto wires this property.
- /// </summary>
- public ICacheClient CacheClient { get; set; }
-
- public override object OnGet(CachedOrders request)
- {
- var cacheKey = UrnId.Create<Orders>(request.CustomerId ?? "all", request.Page.GetValueOrDefault(0).ToString());
- return base.RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey, () =>
- {
- return (OrdersResponse)this.ResolveService<OrdersService>()
- .Get(new Orders { CustomerId = request.CustomerId, Page = request.Page });
- });
- }
- }
-
-}
+using ServiceStack.Common;
+using ServiceStack.Northwind.ServiceModel.Operations;
+using ServiceStack.ServiceHost;
+
+namespace ServiceStack.Northwind.ServiceInterface
+{
+ /// <summary>
+ /// Create your ServiceStack RESTful web service implementation.
+ /// </summary>
+ public class CachedCustomersService : ServiceStack.ServiceInterface.Service
+ {
+ public object Get(CachedCustomers request)
+ {
+ //Manually create the Unified Resource Name "urn:customers".
+ return base.RequestContext.ToOptimizedResultUsingCache(base.Cache, "urn:customers", () =>
+ {
+ //Resolve the service in order to get the customers.
+ using (var service = this.ResolveService<CustomersService>())
+ return service.Get(new Customers());
+ });
+ }
+
+ public object Get(CachedCustomerDetails request)
+ {
+ //Create the Unified Resource Name "urn:customerdetails:{id}".
+ var cacheKey = UrnId.Create<CustomerDetails>(request.Id);
+ return base.RequestContext.ToOptimizedResultUsingCache(base.Cache, cacheKey, () =>
+ {
+ using (var service = this.ResolveService<CustomerDetailsService>())
+ {
+ return service.Get(new CustomerDetails { Id = request.Id });
+ }
+ });
+ }
+
+ public object Get(CachedOrders request)
+ {
+ var cacheKey = UrnId.Create<Orders>(request.CustomerId ?? "all", request.Page.GetValueOrDefault(0).ToString());
+ return base.RequestContext.ToOptimizedResultUsingCache(this.Cache, cacheKey, () =>
+ {
+ using(var service = this.ResolveService<OrdersService>())
+ {
+ return service.Get(new Orders { CustomerId = request.CustomerId, Page = request.Page });
+ }
+ });
+ }
+ }
+
+}
@@ -1,37 +1,32 @@
-using System;
-using System.Net;
-using ServiceStack.Common.Web;
-using ServiceStack.Northwind.ServiceModel.Operations;
-using ServiceStack.Northwind.ServiceModel.Types;
-using ServiceStack.OrmLite;
-using ServiceStack.ServiceInterface;
-
-namespace ServiceStack.Northwind.ServiceInterface
-{
- /// <summary>
- /// Create your ServiceStack RESTful web service implementation.
- /// </summary>
- public class CustomerDetailsService : RestServiceBase<CustomerDetails>
- {
- /// <summary>
- /// Gets or sets the database factory. The built-in IoC used with ServiceStack auto wires this property.
- /// </summary>
- public IDbConnectionFactory DbFactory { get; set; }
-
- public override object OnGet(CustomerDetails request)
- {
- var customer = DbFactory.Run(dbCmd => dbCmd.GetByIdOrDefault<Customer>(request.Id));
- if (customer == null)
- throw new HttpError(HttpStatusCode.NotFound, new ArgumentException("Customer does not exist: " + request.Id));
-
- var ordersService = base.ResolveService<OrdersService>();
- var ordersResponse = (OrdersResponse)ordersService.Get(new Orders { CustomerId = customer.Id });
-
- return new CustomerDetailsResponse
- {
- Customer = customer,
- CustomerOrders = ordersResponse.Results,
- };
- }
- }
-}
+using System;
+using System.Net;
+using ServiceStack.Common.Web;
+using ServiceStack.Northwind.ServiceModel.Operations;
+using ServiceStack.Northwind.ServiceModel.Types;
+using ServiceStack.OrmLite;
+
+namespace ServiceStack.Northwind.ServiceInterface
+{
+ /// <summary>
+ /// Create your ServiceStack RESTful web service implementation.
+ /// </summary>
+ public class CustomerDetailsService : ServiceStack.ServiceInterface.Service
+ {
+ public CustomerDetailsResponse Get(CustomerDetails request)
+ {
+ var customer = Db.IdOrDefault<Customer>(request.Id);
+ if (customer == null)
+ throw new HttpError(HttpStatusCode.NotFound, new ArgumentException("Customer does not exist: " + request.Id));
+
+ using (var ordersService = base.ResolveService<OrdersService>())
+ {
+ var ordersResponse = ordersService.Get(new Orders { CustomerId = customer.Id });
+
+ return new CustomerDetailsResponse {
+ Customer = customer,
+ CustomerOrders = ordersResponse.Results,
+ };
+ }
+ }
+ }
+}
@@ -1,23 +1,17 @@
-using ServiceStack.Northwind.ServiceModel.Operations;
-using ServiceStack.Northwind.ServiceModel.Types;
-using ServiceStack.OrmLite;
-using ServiceStack.ServiceInterface;
-
-namespace ServiceStack.Northwind.ServiceInterface
-{
- /// <summary>
- /// Create your ServiceStack RESTful web service implementation.
- /// </summary>
- public class CustomersService : RestServiceBase<Customers>
- {
- /// <summary>
- /// Gets or sets the database factory. The built-in IoC used with ServiceStack auto wires this property.
- /// </summary>
- public IDbConnectionFactory DbFactory { get; set; }
-
- public override object OnGet(Customers request)
- {
- return new CustomersResponse { Customers = DbFactory.Run(dbCmd => dbCmd.Select<Customer>()) };
- }
- }
-}
+using ServiceStack.Northwind.ServiceModel.Operations;
+using ServiceStack.Northwind.ServiceModel.Types;
+using ServiceStack.OrmLite;
+
+namespace ServiceStack.Northwind.ServiceInterface
+{
+ /// <summary>
+ /// Create your ServiceStack RESTful web service implementation.
+ /// </summary>
+ public class CustomersService : ServiceStack.ServiceInterface.Service
+ {
+ public CustomersResponse Get(Customers request)
+ {
+ return new CustomersResponse { Customers = base.Db.Select<Customer>() };
+ }
+ }
+}
@@ -1,48 +1,38 @@
-using System.Linq;
-using ServiceStack.Common.Extensions;
-using ServiceStack.Northwind.ServiceModel.Operations;
-using ServiceStack.Northwind.ServiceModel.Types;
-using ServiceStack.OrmLite;
-using ServiceStack.ServiceInterface;
-
-namespace ServiceStack.Northwind.ServiceInterface
-{
- /// <summary>
- /// Create your ServiceStack RESTful web service implementation.
- /// </summary>
- public class OrdersService : RestServiceBase<Orders>
- {
- private const int PageCount = 20;
-
- /// <summary>
- /// Gets or sets the database factory. The built-in IoC used with ServiceStack auto wires this property.
- /// </summary>
- public IDbConnectionFactory DbFactory { get; set; }
-
- public override object OnGet(Orders request)
- {
- using (var dbConn = DbFactory.OpenDbConnection())
- {
- var orders = request.CustomerId.IsNullOrEmpty()
- ? dbConn.Select<Order>("ORDER BY OrderDate DESC LIMIT {0}, {1}", (request.Page.GetValueOrDefault(1) - 1) * PageCount, PageCount)
- : dbConn.Select<Order>("CustomerId = {0}", request.CustomerId);
-
- if (orders.Count == 0) { return new OrdersResponse(); }
-
- var orderDetails = dbConn.Select<OrderDetail>(
- "OrderId IN ({0})", new SqlInValues(orders.ConvertAll(x => x.Id)));
-
- var orderDetailsLookup = orderDetails.ToLookup(o => o.OrderId);
-
- var customerOrders = orders.ConvertAll(o =>
- new CustomerOrder
- {
- Order = o,
- OrderDetails = orderDetailsLookup[o.Id].ToList()
- });
-
- return new OrdersResponse { Results = customerOrders };
- }
- }
- }
-}
+using System.Linq;
+using ServiceStack.Common.Extensions;
+using ServiceStack.Northwind.ServiceModel.Operations;
+using ServiceStack.Northwind.ServiceModel.Types;
+using ServiceStack.OrmLite;
+
+namespace ServiceStack.Northwind.ServiceInterface
+{
+ /// <summary>
+ /// Create your ServiceStack RESTful web service implementation.
+ /// </summary>
+ public class OrdersService : ServiceStack.ServiceInterface.Service
+ {
+ private const int PageCount = 20;
+
+ public OrdersResponse Get(Orders request)
+ {
+ var orders = request.CustomerId.IsNullOrEmpty()
+ ? Db.Select<Order>("ORDER BY OrderDate DESC LIMIT {0}, {1}", (request.Page.GetValueOrDefault(1) - 1) * PageCount, PageCount)
+ : Db.Select<Order>("CustomerId = {0}", request.CustomerId);
+
+ if (orders.Count == 0) { return new OrdersResponse(); }
+
+ var orderDetails = Db.Select<OrderDetail>(
+ "OrderId IN ({0})", new SqlInValues(orders.ConvertAll(x => x.Id)));
+
+ var orderDetailsLookup = orderDetails.ToLookup(o => o.OrderId);
+
+ var customerOrders = orders.ConvertAll(o =>
+ new CustomerOrder {
+ Order = o,
+ OrderDetails = orderDetailsLookup[o.Id].ToList()
+ });
+
+ return new OrdersResponse { Results = customerOrders };
+ }
+ }
+}
@@ -54,31 +54,28 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="ServiceStack">
- <HintPath>..\..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.3.9.32\lib\net35\ServiceStack.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Common">
- <HintPath>..\..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Common.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.Common.3.9.32\lib\net35\ServiceStack.Common.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces">
- <HintPath>..\..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Interfaces.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.Common.3.9.32\lib\net35\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.OrmLite">
- <HintPath>..\..\packages\ServiceStack.OrmLite.SqlServer.3.9.9\lib\ServiceStack.OrmLite.dll</HintPath>
- </Reference>
- <Reference Include="ServiceStack.OrmLite.SqliteNET">
- <HintPath>..\..\packages\ServiceStack.OrmLite.Sqlite32.3.9.9\lib\net35\ServiceStack.OrmLite.SqliteNET.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.32\lib\ServiceStack.OrmLite.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.OrmLite.SqlServer">
- <HintPath>..\..\packages\ServiceStack.OrmLite.SqlServer.3.9.9\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.32\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Redis">
- <HintPath>..\..\packages\ServiceStack.Redis.3.9.11\lib\net35\ServiceStack.Redis.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.Redis.3.9.32\lib\net35\ServiceStack.Redis.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.ServiceInterface">
- <HintPath>..\..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.ServiceInterface.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.3.9.32\lib\net35\ServiceStack.ServiceInterface.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text">
- <HintPath>..\..\packages\ServiceStack.Text.3.9.11\lib\net35\ServiceStack.Text.dll</HintPath>
+ <HintPath>..\packages\ServiceStack.Text.3.9.32\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack" version="3.9.11" targetFramework="net35" />
+ <package id="ServiceStack" version="3.9.32" targetFramework="net35" />
<package id="ServiceStack.Common" version="3.9.11" targetFramework="net35" />
+ <package id="ServiceStack.Common" version="3.9.32" targetFramework="net35" />
<package id="ServiceStack.OrmLite.Sqlite32" version="3.9.9" targetFramework="net35" />
<package id="ServiceStack.OrmLite.SqlServer" version="3.9.9" targetFramework="net35" />
+ <package id="ServiceStack.OrmLite.SqlServer" version="3.9.32" targetFramework="net35" />
<package id="ServiceStack.Redis" version="3.9.11" targetFramework="net35" />
+ <package id="ServiceStack.Redis" version="3.9.32" targetFramework="net35" />
<package id="ServiceStack.Text" version="3.9.11" targetFramework="net35" />
+ <package id="ServiceStack.Text" version="3.9.32" targetFramework="net35" />
</packages>
@@ -1,4 +1,3 @@
-using System.Runtime.Serialization;
using ServiceStack.ServiceHost;
namespace ServiceStack.Northwind.ServiceModel.Operations
Oops, something went wrong.

0 comments on commit 5c2dc43

Please sign in to comment.