Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

more stuff

  • Loading branch information...
commit 1b6bb8ecf5cc62d2f0ddffc46bd15a40a5db7252 1 parent 8237959
Allen Gay authored

Showing 54 changed files with 939 additions and 376 deletions. Show diff stats Hide diff stats

  1. +99 97 Api.Contracts/Api.Contracts.csproj
  2. +2 0  Api.Contracts/Repositories/IAccountApplicationRepository.cs
  3. +1 1  Api.Contracts/Repositories/IAccountUserRepository.cs
  4. +22 0 Api.Contracts/Services/IApplicationBreadService.cs
  5. +14 0 Api.Contracts/Services/IUserBreadService.cs
  6. +5 7 Api.Contracts/Services/IUserRegistrationService.cs
  7. +0 9 Api.Contracts/dto/ApplicationRequest.cs
  8. +0 11 Api.Contracts/dto/GetUserRequest.cs
  9. +0 8 Api.Contracts/dto/RegisterAccountRequest.cs
  10. +0 8 Api.Contracts/dto/RegisterAccountUserRequest.cs
  11. +127 124 Api.Implementations/Api.Implementations.csproj
  12. +56 0 Api.Implementations/HandlerMapper.cs
  13. +36 1 Api.Implementations/Registration.cs
  14. +14 0 Api.Implementations/Repositories/AccountApplicationRepository.cs
  15. +6 6 Api.Implementations/Repositories/AccountUserRepository.cs
  16. +9 11 Api.Implementations/Repositories/BaseDataItemRepository.cs
  17. +57 0 Api.Implementations/Services/ApplicationBreadService.cs
  18. +45 0 Api.Implementations/Services/UserBreadService.cs
  19. +24 7 Api.RestHandlers/Api.RestHandlers.csproj
  20. +21 0 Api.RestHandlers/Handlers/AddApplicationRequestHandler.cs
  21. +22 0 Api.RestHandlers/Handlers/AddApplicationServiceRequestHandler.cs
  22. +21 0 Api.RestHandlers/Handlers/BrowseAccountUsersRequestHandler.cs
  23. +21 0 Api.RestHandlers/Handlers/BrowseApplicationServicesRequestHandler.cs
  24. +21 0 Api.RestHandlers/Handlers/BrowseApplicationsRequestHandler.cs
  25. +22 0 Api.RestHandlers/Handlers/DeleteApplicationRequestHandler.cs
  26. +21 0 Api.RestHandlers/Handlers/DeleteApplicationServiceRequestHandler.cs
  27. +1 1  Api.RestHandlers/{ → Handlers}/EmptyExampleHandler.cs
  28. +21 0 Api.RestHandlers/Handlers/GetApplicationRequestHandler.cs
  29. +1 1  Api.RestHandlers/{ → Handlers}/GetRegistrationHtmlHandler.cs
  30. +1 1  Api.RestHandlers/{ → Handlers}/GetServiceTokenForPrincipalIdHandler.cs
  31. +2 1  Api.RestHandlers/{ → Handlers}/GetSupportedServicesHandler.cs
  32. +21 0 Api.RestHandlers/Handlers/GetUserRequestHandler.cs
  33. +1 1  Api.RestHandlers/{ → Handlers}/IsRegisteredForServiceHandler.cs
  34. +22 0 Api.RestHandlers/Handlers/RegisterAccountRequestHandler.cs
  35. +20 0 Api.RestHandlers/Handlers/RegisterAccountUserRequestHandler.cs
  36. +1 1  Api.RestHandlers/{ → Handlers}/RegisterServiceProviderRequestHandler.cs
  37. +1 1  Api.RestHandlers/{ → Handlers}/RegisterServiceTokenHandler.cs
  38. +41 0 Api.RestHandlers/RequiresAppRegistrationAttribute.cs
  39. +17 0 Api.RestHandlers/Validators/ApplicationRequestValidator.cs
  40. +19 0 Api.RestHandlers/Validators/GetSupportedServicesRequestValidator.cs
  41. +12 1 Api.RestServiceHost/Api.RestServiceHost.csproj
  42. +4 1 Api.RestServiceHost/App_Start/AppHost.cs
  43. +11 14 Core/DataConnectionProvider.cs
  44. +3 3 Core/IDataConnectionProvider.cs
  45. +1 1  Core/ServiceRegistration.cs
  46. +1 0  Data/DataItem.cs
  47. +36 39 Data/DataItemRepository.cs
  48. +12 1 Demo/Demo.csproj
  49. +12 18 FederatedOauthConsumer.sln
  50. BIN  UpgradeLog.htm
  51. +12 1 YammerService/yammerservice.csproj
  52. BIN  _TeamCity.FederatedOauthConsumer/AssemblyInfoCache.dat
  53. BIN  _TeamCity.FederatedOauthConsumer/ProjectFileDataCache/ShouldUseHostCompilerProvider.cache.dat
  54. BIN  _TeamCity.FederatedOauthConsumer/ProjectModel/projectModel.dat
196 Api.Contracts/Api.Contracts.csproj
... ... @@ -1,98 +1,100 @@
1   -<?xml version="1.0" encoding="utf-8"?>
2   -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3   - <PropertyGroup>
4   - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5   - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6   - <ProductVersion>8.0.30703</ProductVersion>
7   - <SchemaVersion>2.0</SchemaVersion>
8   - <ProjectGuid>{465D9510-43D7-4C51-8B11-1FB57D6A7C9D}</ProjectGuid>
9   - <OutputType>Library</OutputType>
10   - <AppDesignerFolder>Properties</AppDesignerFolder>
11   - <RootNamespace>Api.Contracts</RootNamespace>
12   - <AssemblyName>Api.Contracts</AssemblyName>
13   - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14   - <FileAlignment>512</FileAlignment>
15   - </PropertyGroup>
16   - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17   - <DebugSymbols>true</DebugSymbols>
18   - <DebugType>full</DebugType>
19   - <Optimize>false</Optimize>
20   - <OutputPath>bin\Debug\</OutputPath>
21   - <DefineConstants>DEBUG;TRACE</DefineConstants>
22   - <ErrorReport>prompt</ErrorReport>
23   - <WarningLevel>4</WarningLevel>
24   - </PropertyGroup>
25   - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26   - <DebugType>pdbonly</DebugType>
27   - <Optimize>true</Optimize>
28   - <OutputPath>bin\Release\</OutputPath>
29   - <DefineConstants>TRACE</DefineConstants>
30   - <ErrorReport>prompt</ErrorReport>
31   - <WarningLevel>4</WarningLevel>
32   - </PropertyGroup>
33   - <ItemGroup>
34   - <Reference Include="System" />
35   - <Reference Include="System.Core" />
36   - <Reference Include="System.Xml.Linq" />
37   - <Reference Include="System.Data.DataSetExtensions" />
38   - <Reference Include="Microsoft.CSharp" />
39   - <Reference Include="System.Data" />
40   - <Reference Include="System.Xml" />
41   - </ItemGroup>
42   - <ItemGroup>
43   - <Compile Include="DTO\AddApplicationRequest.cs" />
44   - <Compile Include="DTO\AddApplicationServiceRequest.cs" />
45   - <Compile Include="DTO\ApplicationRequest.cs" />
46   - <Compile Include="DTO\BrowseAccountUsersRequest.cs" />
47   - <Compile Include="DTO\BrowseApplicationServicesRequest.cs" />
48   - <Compile Include="DTO\BrowseApplicationsRequest.cs" />
49   - <Compile Include="DTO\DeleteApplicationRequest.cs" />
50   - <Compile Include="DTO\DeleteApplicationServiceRequest.cs" />
51   - <Compile Include="DTO\EnumerableResponse.cs" />
52   - <Compile Include="DTO\GetApplicationRequest.cs" />
53   - <Compile Include="DTO\GetServiceTokenForPrincipalIdResponse.cs" />
54   - <Compile Include="DTO\GetServiceTokenForPrincipalIdRequest.cs" />
55   - <Compile Include="DTO\GetUserRequest.cs" />
56   - <Compile Include="DTO\IsRegisteredForServiceResponse.cs" />
57   - <Compile Include="DTO\GetRegistrationHtmlRequest.cs" />
58   - <Compile Include="DTO\GetRegistrationHtmlResponse.cs" />
59   - <Compile Include="DTO\GetSupportedServicesRequest.cs" />
60   - <Compile Include="DTO\GetSupportedServicesResponse.cs" />
61   - <Compile Include="DTO\IsRegisteredForServiceRequest.cs" />
62   - <Compile Include="DTO\RegisterAccountRequest.cs" />
63   - <Compile Include="DTO\RegisterAccountUserRequest.cs" />
64   - <Compile Include="DTO\RegisterServiceProviderRequest.cs" />
65   - <Compile Include="DTO\RegisterServiceTokenRequest.cs" />
66   - <Compile Include="EmptyDto.cs" />
67   - <Compile Include="Properties\AssemblyInfo.cs" />
68   - <Compile Include="Repositories\IAccountApplicationRepository.cs" />
69   - <Compile Include="Repositories\IAccountRepository.cs" />
70   - <Compile Include="Repositories\IAccountUserRepository.cs" />
71   - <Compile Include="Repositories\IApplicationRepository.cs" />
72   - <Compile Include="Repositories\IApplicationServiceRepository.cs" />
73   - <Compile Include="Repositories\IServiceProviderRepository.cs" />
74   - <Compile Include="Repositories\ISimpleDataItemRepository.cs" />
75   - <Compile Include="Repositories\IUserRepository.cs" />
76   - <Compile Include="Repositories\IUserTokenRepository.cs" />
77   - <Compile Include="Services\IApplicationAuthenticationService.cs" />
78   - <Compile Include="Services\IAuthConsumerService.cs" />
79   - <Compile Include="Services\IAuthProviderInstance.cs" />
80   - <Compile Include="Services\IAuthProviderFactory.cs" />
81   - <Compile Include="Services\IUserRegistrationService.cs" />
82   - </ItemGroup>
83   - <ItemGroup>
84   - <ProjectReference Include="..\Data\Data.csproj">
85   - <Project>{B40B33E8-B802-4384-8F22-F7670B060566}</Project>
86   - <Name>Data</Name>
87   - </ProjectReference>
88   - </ItemGroup>
89   - <ItemGroup />
90   - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
91   - <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
92   - Other similar extension points exist, see Microsoft.Common.targets.
93   - <Target Name="BeforeBuild">
94   - </Target>
95   - <Target Name="AfterBuild">
96   - </Target>
97   - -->
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3 + <PropertyGroup>
  4 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  5 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  6 + <ProductVersion>8.0.30703</ProductVersion>
  7 + <SchemaVersion>2.0</SchemaVersion>
  8 + <ProjectGuid>{465D9510-43D7-4C51-8B11-1FB57D6A7C9D}</ProjectGuid>
  9 + <OutputType>Library</OutputType>
  10 + <AppDesignerFolder>Properties</AppDesignerFolder>
  11 + <RootNamespace>Api.Contracts</RootNamespace>
  12 + <AssemblyName>Api.Contracts</AssemblyName>
  13 + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
  14 + <FileAlignment>512</FileAlignment>
  15 + </PropertyGroup>
  16 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  17 + <DebugSymbols>true</DebugSymbols>
  18 + <DebugType>full</DebugType>
  19 + <Optimize>false</Optimize>
  20 + <OutputPath>bin\Debug\</OutputPath>
  21 + <DefineConstants>DEBUG;TRACE</DefineConstants>
  22 + <ErrorReport>prompt</ErrorReport>
  23 + <WarningLevel>4</WarningLevel>
  24 + </PropertyGroup>
  25 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  26 + <DebugType>pdbonly</DebugType>
  27 + <Optimize>true</Optimize>
  28 + <OutputPath>bin\Release\</OutputPath>
  29 + <DefineConstants>TRACE</DefineConstants>
  30 + <ErrorReport>prompt</ErrorReport>
  31 + <WarningLevel>4</WarningLevel>
  32 + </PropertyGroup>
  33 + <ItemGroup>
  34 + <Reference Include="System" />
  35 + <Reference Include="System.Core" />
  36 + <Reference Include="System.Xml.Linq" />
  37 + <Reference Include="System.Data.DataSetExtensions" />
  38 + <Reference Include="Microsoft.CSharp" />
  39 + <Reference Include="System.Data" />
  40 + <Reference Include="System.Xml" />
  41 + </ItemGroup>
  42 + <ItemGroup>
  43 + <Compile Include="DTO\AddApplicationRequest.cs" />
  44 + <Compile Include="DTO\AddApplicationServiceRequest.cs" />
  45 + <Compile Include="DTO\ApplicationRequest.cs" />
  46 + <Compile Include="DTO\BrowseAccountUsersRequest.cs" />
  47 + <Compile Include="DTO\BrowseApplicationServicesRequest.cs" />
  48 + <Compile Include="DTO\BrowseApplicationsRequest.cs" />
  49 + <Compile Include="DTO\DeleteApplicationRequest.cs" />
  50 + <Compile Include="DTO\DeleteApplicationServiceRequest.cs" />
  51 + <Compile Include="DTO\EnumerableResponse.cs" />
  52 + <Compile Include="DTO\GetApplicationRequest.cs" />
  53 + <Compile Include="DTO\GetServiceTokenForPrincipalIdResponse.cs" />
  54 + <Compile Include="DTO\GetServiceTokenForPrincipalIdRequest.cs" />
  55 + <Compile Include="DTO\GetUserRequest.cs" />
  56 + <Compile Include="DTO\IsRegisteredForServiceResponse.cs" />
  57 + <Compile Include="DTO\GetRegistrationHtmlRequest.cs" />
  58 + <Compile Include="DTO\GetRegistrationHtmlResponse.cs" />
  59 + <Compile Include="DTO\GetSupportedServicesRequest.cs" />
  60 + <Compile Include="DTO\GetSupportedServicesResponse.cs" />
  61 + <Compile Include="DTO\IsRegisteredForServiceRequest.cs" />
  62 + <Compile Include="DTO\RegisterAccountRequest.cs" />
  63 + <Compile Include="DTO\RegisterAccountUserRequest.cs" />
  64 + <Compile Include="DTO\RegisterServiceProviderRequest.cs" />
  65 + <Compile Include="DTO\RegisterServiceTokenRequest.cs" />
  66 + <Compile Include="EmptyDto.cs" />
  67 + <Compile Include="Properties\AssemblyInfo.cs" />
  68 + <Compile Include="Repositories\IAccountApplicationRepository.cs" />
  69 + <Compile Include="Repositories\IAccountRepository.cs" />
  70 + <Compile Include="Repositories\IAccountUserRepository.cs" />
  71 + <Compile Include="Repositories\IApplicationRepository.cs" />
  72 + <Compile Include="Repositories\IApplicationServiceRepository.cs" />
  73 + <Compile Include="Repositories\IServiceProviderRepository.cs" />
  74 + <Compile Include="Repositories\ISimpleDataItemRepository.cs" />
  75 + <Compile Include="Repositories\IUserRepository.cs" />
  76 + <Compile Include="Repositories\IUserTokenRepository.cs" />
  77 + <Compile Include="Services\IApplicationAuthenticationService.cs" />
  78 + <Compile Include="Services\IApplicationBreadService.cs" />
  79 + <Compile Include="Services\IAuthConsumerService.cs" />
  80 + <Compile Include="Services\IAuthProviderInstance.cs" />
  81 + <Compile Include="Services\IAuthProviderFactory.cs" />
  82 + <Compile Include="Services\IUserBreadService.cs" />
  83 + <Compile Include="Services\IUserRegistrationService.cs" />
  84 + </ItemGroup>
  85 + <ItemGroup>
  86 + <ProjectReference Include="..\Data\Data.csproj">
  87 + <Project>{B40B33E8-B802-4384-8F22-F7670B060566}</Project>
  88 + <Name>Data</Name>
  89 + </ProjectReference>
  90 + </ItemGroup>
  91 + <ItemGroup />
  92 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  93 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  94 + Other similar extension points exist, see Microsoft.Common.targets.
  95 + <Target Name="BeforeBuild">
  96 + </Target>
  97 + <Target Name="AfterBuild">
  98 + </Target>
  99 + -->
98 100 </Project>
2  Api.Contracts/Repositories/IAccountApplicationRepository.cs
@@ -6,5 +6,7 @@ namespace Api.Contracts.Repositories
6 6 public interface IAccountApplicationRepository : ISimpleDataItemRepository<AccountApplication>
7 7 {
8 8 IEnumerable<AccountApplication> GetForAccount(int accountId);
  9 +
  10 + Account GetForApplication(int applicationId);
9 11 }
10 12 }
2  Api.Contracts/Repositories/IAccountUserRepository.cs
@@ -5,6 +5,6 @@ namespace Api.Contracts.Repositories
5 5 {
6 6 public interface IAccountUserRepository : ISimpleDataItemRepository<AccountUser>
7 7 {
8   - IEnumerable<AccountUser> GetForAccount(int accountId);
  8 + IEnumerable<User> GetForAccount(int accountId);
9 9 }
10 10 }
22 Api.Contracts/Services/IApplicationBreadService.cs
... ... @@ -0,0 +1,22 @@
  1 +using Api.Contracts.DTO;
  2 +using Data;
  3 +
  4 +namespace Api.Contracts.Services
  5 +{
  6 + public interface IApplicationBreadService
  7 + {
  8 + Application GetApplication(GetApplicationRequest request);
  9 +
  10 + Application RegisterApplicationForAccount(AddApplicationRequest request);
  11 +
  12 + ApplicationService RegisterServiceForApplication(AddApplicationServiceRequest request);
  13 +
  14 + EnumerableResponse<ApplicationService> BrowseServicesForApplication(BrowseApplicationServicesRequest request);
  15 +
  16 + EnumerableResponse<Application> BrowseApplications(BrowseApplicationsRequest request);
  17 +
  18 + void DeleteApplication(DeleteApplicationRequest request);
  19 +
  20 + void DeleteApplicationService(DeleteApplicationServiceRequest request);
  21 + }
  22 +}
14 Api.Contracts/Services/IUserBreadService.cs
... ... @@ -0,0 +1,14 @@
  1 +using Api.Contracts.DTO;
  2 +using Data;
  3 +
  4 +namespace Api.Contracts.Services
  5 +{
  6 + public interface IUserBreadService
  7 + {
  8 + EnumerableResponse<User> BrowseUsersForAccount(BrowseAccountUsersRequest request);
  9 +
  10 + User RegisterUserForAccount(RegisterAccountUserRequest request);
  11 +
  12 + User GetUser(GetUserRequest request);
  13 + }
  14 +}
12 Api.Contracts/Services/IUserRegistrationService.cs
... ... @@ -1,15 +1,13 @@
1   -using Data;
  1 +using Api.Contracts.DTO;
  2 +using Data;
2 3
3 4 namespace Api.Contracts.Services
4 5 {
5 6 public interface IAccountRegistrationService
6 7 {
7   - void RegisterUser(RegisterUser request);
  8 + void RegisterAccountForUser(RegisterAccountRequest request);
8 9
9   - void RegisterAccountForUser(RegisterAccount request);
10   -
11   - void RegisterAuthServiceForAccount(RegisterAuthServiceProvider request);
12   -
  10 + void RegisterAuthServiceForAccount(RegisterAuthServiceProvider request);
13 11 }
14 12
15 13 public class RegisterAuthServiceProvider
@@ -20,7 +18,7 @@ public class RegisterAccount
20 18 {
21 19 }
22 20
23   - public class RegisterUser
  21 + public class RegisterUserRequest
24 22 {
25 23
26 24 }
9 Api.Contracts/dto/ApplicationRequest.cs
... ... @@ -1,9 +0,0 @@
1   -namespace Api.Contracts.Dto
2   -{
3   - public abstract class ApplicationRequest
4   - {
5   - public string AppKey { get; set; }
6   -
7   - public string AppSecret { get; set; }
8   - }
9   -}
11 Api.Contracts/dto/GetUserRequest.cs
... ... @@ -1,11 +0,0 @@
1   -using Api.Contracts.Dto;
2   -
3   -namespace Api.Contracts.DTO
4   -{
5   - public class GetUserRequest: ApplicationRequest
6   - {
7   - public string Id { get; set; }
8   -
9   - public string UserId { get; set; }
10   - }
11   -}
8 Api.Contracts/dto/RegisterAccountRequest.cs
... ... @@ -1,8 +0,0 @@
1   -using Api.Contracts.Dto;
2   -
3   -namespace Api.Contracts.DTO
4   -{
5   - public class RegisterAccountRequest : ApplicationRequest
6   - {
7   - }
8   -}
8 Api.Contracts/dto/RegisterAccountUserRequest.cs
... ... @@ -1,8 +0,0 @@
1   -using Api.Contracts.Dto;
2   -
3   -namespace Api.Contracts.DTO
4   -{
5   - public class RegisterAccountUserRequest : ApplicationRequest
6   - {
7   - }
8   -}
251 Api.Implementations/Api.Implementations.csproj
... ... @@ -1,125 +1,128 @@
1   -<?xml version="1.0" encoding="utf-8"?>
2   -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3   - <PropertyGroup>
4   - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5   - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6   - <ProductVersion>8.0.30703</ProductVersion>
7   - <SchemaVersion>2.0</SchemaVersion>
8   - <ProjectGuid>{6B511690-28B0-400D-97EA-8EE7B3046F91}</ProjectGuid>
9   - <OutputType>Library</OutputType>
10   - <AppDesignerFolder>Properties</AppDesignerFolder>
11   - <RootNamespace>Api.Implementations</RootNamespace>
12   - <AssemblyName>Api.Implementations</AssemblyName>
13   - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14   - <FileAlignment>512</FileAlignment>
15   - </PropertyGroup>
16   - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17   - <DebugSymbols>true</DebugSymbols>
18   - <DebugType>full</DebugType>
19   - <Optimize>false</Optimize>
20   - <OutputPath>bin\Debug\</OutputPath>
21   - <DefineConstants>DEBUG;TRACE</DefineConstants>
22   - <ErrorReport>prompt</ErrorReport>
23   - <WarningLevel>4</WarningLevel>
24   - </PropertyGroup>
25   - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26   - <DebugType>pdbonly</DebugType>
27   - <Optimize>true</Optimize>
28   - <OutputPath>bin\Release\</OutputPath>
29   - <DefineConstants>TRACE</DefineConstants>
30   - <ErrorReport>prompt</ErrorReport>
31   - <WarningLevel>4</WarningLevel>
32   - </PropertyGroup>
33   - <ItemGroup>
34   - <Reference Include="ServiceStack, Version=3.9.4.0, Culture=neutral, processorArchitecture=MSIL">
35   - <SpecificVersion>False</SpecificVersion>
36   - <HintPath>..\packages\ServiceStack.3.9.5\lib\net40\ServiceStack.dll</HintPath>
37   - </Reference>
38   - <Reference Include="ServiceStack.Common, Version=3.9.4.0, Culture=neutral, processorArchitecture=MSIL">
39   - <SpecificVersion>False</SpecificVersion>
40   - <HintPath>..\packages\ServiceStack.Common.3.9.5\lib\net35\ServiceStack.Common.dll</HintPath>
41   - </Reference>
42   - <Reference Include="ServiceStack.Interfaces, Version=3.9.0.0, Culture=neutral, processorArchitecture=MSIL">
43   - <SpecificVersion>False</SpecificVersion>
44   - <HintPath>..\packages\ServiceStack.Common.3.9.5\lib\net35\ServiceStack.Interfaces.dll</HintPath>
45   - </Reference>
46   - <Reference Include="ServiceStack.OrmLite, Version=3.9.5.0, Culture=neutral, processorArchitecture=MSIL">
47   - <SpecificVersion>False</SpecificVersion>
48   - <HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.5\lib\ServiceStack.OrmLite.dll</HintPath>
49   - </Reference>
50   - <Reference Include="ServiceStack.OrmLite.SqlServer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
51   - <HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.5\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
52   - </Reference>
53   - <Reference Include="ServiceStack.Razor">
54   - <HintPath>..\packages\ServiceStack.3.9.5\lib\net40\ServiceStack.Razor.dll</HintPath>
55   - </Reference>
56   - <Reference Include="ServiceStack.Redis">
57   - <HintPath>..\packages\ServiceStack.Redis.3.9.5\lib\net35\ServiceStack.Redis.dll</HintPath>
58   - </Reference>
59   - <Reference Include="ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
60   - <SpecificVersion>False</SpecificVersion>
61   - <HintPath>..\packages\ServiceStack.3.9.5\lib\net40\ServiceStack.ServiceInterface.dll</HintPath>
62   - </Reference>
63   - <Reference Include="ServiceStack.Text, Version=3.9.5.0, Culture=neutral, processorArchitecture=MSIL">
64   - <SpecificVersion>False</SpecificVersion>
65   - <HintPath>..\packages\ServiceStack.Text.3.9.5\lib\net35\ServiceStack.Text.dll</HintPath>
66   - </Reference>
67   - <Reference Include="System" />
68   - <Reference Include="System.Configuration" />
69   - <Reference Include="System.Core" />
70   - <Reference Include="System.Xml.Linq" />
71   - <Reference Include="System.Data.DataSetExtensions" />
72   - <Reference Include="Microsoft.CSharp" />
73   - <Reference Include="System.Data" />
74   - <Reference Include="System.Xml" />
75   - </ItemGroup>
76   - <ItemGroup>
77   - <Compile Include="Properties\AssemblyInfo.cs" />
78   - <Compile Include="Registration.cs" />
79   - <Compile Include="Repositories\AccountApplicationRepository.cs" />
80   - <Compile Include="Repositories\AccountRepository.cs" />
81   - <Compile Include="Repositories\AccountUserRepository.cs" />
82   - <Compile Include="Repositories\ApplicationRepository.cs" />
83   - <Compile Include="Repositories\ApplicationServiceRepository.cs" />
84   - <Compile Include="Repositories\BaseDataItemRepository.cs" />
85   - <Compile Include="Repositories\ServiceProviderRepository.cs" />
86   - <Compile Include="Repositories\UserRepository.cs" />
87   - <Compile Include="Repositories\UserTokenRecordRepository.cs" />
88   - <Compile Include="Services\ApplicationAuthenticationService.cs" />
89   - <Compile Include="Services\AuthConsumerService.cs" />
90   - <Compile Include="Services\AuthProviderFactory.cs" />
91   - <Compile Include="Services\FacebookAuthProviderInstance.cs" />
92   - <Compile Include="Services\YammerAuthProviderInstance.cs" />
93   - </ItemGroup>
94   - <ItemGroup>
95   - <ProjectReference Include="..\Api.Contracts\Api.Contracts.csproj">
96   - <Project>{465D9510-43D7-4C51-8B11-1FB57D6A7C9D}</Project>
97   - <Name>Api.Contracts</Name>
98   - </ProjectReference>
99   - <ProjectReference Include="..\Core\Core.csproj">
100   - <Project>{1F902AAD-9A34-4530-A3E3-62B0F31A38A5}</Project>
101   - <Name>Core</Name>
102   - </ProjectReference>
103   - <ProjectReference Include="..\Data\Data.csproj">
104   - <Project>{B40B33E8-B802-4384-8F22-F7670B060566}</Project>
105   - <Name>Data</Name>
106   - </ProjectReference>
107   - </ItemGroup>
108   - <ItemGroup>
109   - <Resource Include="Templates\facebook.htm" />
110   - </ItemGroup>
111   - <ItemGroup>
112   - <None Include="packages.config" />
113   - </ItemGroup>
114   - <ItemGroup>
115   - <Folder Include="Handlers\" />
116   - </ItemGroup>
117   - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
118   - <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
119   - Other similar extension points exist, see Microsoft.Common.targets.
120   - <Target Name="BeforeBuild">
121   - </Target>
122   - <Target Name="AfterBuild">
123   - </Target>
124   - -->
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3 + <PropertyGroup>
  4 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  5 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  6 + <ProductVersion>8.0.30703</ProductVersion>
  7 + <SchemaVersion>2.0</SchemaVersion>
  8 + <ProjectGuid>{6B511690-28B0-400D-97EA-8EE7B3046F91}</ProjectGuid>
  9 + <OutputType>Library</OutputType>
  10 + <AppDesignerFolder>Properties</AppDesignerFolder>
  11 + <RootNamespace>Api.Implementations</RootNamespace>
  12 + <AssemblyName>Api.Implementations</AssemblyName>
  13 + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
  14 + <FileAlignment>512</FileAlignment>
  15 + </PropertyGroup>
  16 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  17 + <DebugSymbols>true</DebugSymbols>
  18 + <DebugType>full</DebugType>
  19 + <Optimize>false</Optimize>
  20 + <OutputPath>bin\Debug\</OutputPath>
  21 + <DefineConstants>DEBUG;TRACE</DefineConstants>
  22 + <ErrorReport>prompt</ErrorReport>
  23 + <WarningLevel>4</WarningLevel>
  24 + </PropertyGroup>
  25 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  26 + <DebugType>pdbonly</DebugType>
  27 + <Optimize>true</Optimize>
  28 + <OutputPath>bin\Release\</OutputPath>
  29 + <DefineConstants>TRACE</DefineConstants>
  30 + <ErrorReport>prompt</ErrorReport>
  31 + <WarningLevel>4</WarningLevel>
  32 + </PropertyGroup>
  33 + <ItemGroup>
  34 + <Reference Include="ServiceStack, Version=3.9.4.0, Culture=neutral, processorArchitecture=MSIL">
  35 + <SpecificVersion>False</SpecificVersion>
  36 + <HintPath>..\packages\ServiceStack.3.9.5\lib\net40\ServiceStack.dll</HintPath>
  37 + </Reference>
  38 + <Reference Include="ServiceStack.Common, Version=3.9.4.0, Culture=neutral, processorArchitecture=MSIL">
  39 + <SpecificVersion>False</SpecificVersion>
  40 + <HintPath>..\packages\ServiceStack.Common.3.9.5\lib\net35\ServiceStack.Common.dll</HintPath>
  41 + </Reference>
  42 + <Reference Include="ServiceStack.Interfaces, Version=3.9.0.0, Culture=neutral, processorArchitecture=MSIL">
  43 + <SpecificVersion>False</SpecificVersion>
  44 + <HintPath>..\packages\ServiceStack.Common.3.9.5\lib\net35\ServiceStack.Interfaces.dll</HintPath>
  45 + </Reference>
  46 + <Reference Include="ServiceStack.OrmLite, Version=3.9.5.0, Culture=neutral, processorArchitecture=MSIL">
  47 + <SpecificVersion>False</SpecificVersion>
  48 + <HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.5\lib\ServiceStack.OrmLite.dll</HintPath>
  49 + </Reference>
  50 + <Reference Include="ServiceStack.OrmLite.SqlServer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  51 + <HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.5\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
  52 + </Reference>
  53 + <Reference Include="ServiceStack.Razor">
  54 + <HintPath>..\packages\ServiceStack.3.9.5\lib\net40\ServiceStack.Razor.dll</HintPath>
  55 + </Reference>
  56 + <Reference Include="ServiceStack.Redis">
  57 + <HintPath>..\packages\ServiceStack.Redis.3.9.5\lib\net35\ServiceStack.Redis.dll</HintPath>
  58 + </Reference>
  59 + <Reference Include="ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  60 + <SpecificVersion>False</SpecificVersion>
  61 + <HintPath>..\packages\ServiceStack.3.9.5\lib\net40\ServiceStack.ServiceInterface.dll</HintPath>
  62 + </Reference>
  63 + <Reference Include="ServiceStack.Text, Version=3.9.5.0, Culture=neutral, processorArchitecture=MSIL">
  64 + <SpecificVersion>False</SpecificVersion>
  65 + <HintPath>..\packages\ServiceStack.Text.3.9.5\lib\net35\ServiceStack.Text.dll</HintPath>
  66 + </Reference>
  67 + <Reference Include="System" />
  68 + <Reference Include="System.Configuration" />
  69 + <Reference Include="System.Core" />
  70 + <Reference Include="System.Xml.Linq" />
  71 + <Reference Include="System.Data.DataSetExtensions" />
  72 + <Reference Include="Microsoft.CSharp" />
  73 + <Reference Include="System.Data" />
  74 + <Reference Include="System.Xml" />
  75 + </ItemGroup>
  76 + <ItemGroup>
  77 + <Compile Include="HandlerMapper.cs" />
  78 + <Compile Include="Properties\AssemblyInfo.cs" />
  79 + <Compile Include="Registration.cs" />
  80 + <Compile Include="Repositories\AccountApplicationRepository.cs" />
  81 + <Compile Include="Repositories\AccountRepository.cs" />
  82 + <Compile Include="Repositories\AccountUserRepository.cs" />
  83 + <Compile Include="Repositories\ApplicationRepository.cs" />
  84 + <Compile Include="Repositories\ApplicationServiceRepository.cs" />
  85 + <Compile Include="Repositories\BaseDataItemRepository.cs" />
  86 + <Compile Include="Repositories\ServiceProviderRepository.cs" />
  87 + <Compile Include="Repositories\UserRepository.cs" />
  88 + <Compile Include="Repositories\UserTokenRecordRepository.cs" />
  89 + <Compile Include="Services\ApplicationAuthenticationService.cs" />
  90 + <Compile Include="Services\ApplicationBreadService.cs" />
  91 + <Compile Include="Services\AuthConsumerService.cs" />
  92 + <Compile Include="Services\AuthProviderFactory.cs" />
  93 + <Compile Include="Services\FacebookAuthProviderInstance.cs" />
  94 + <Compile Include="Services\UserBreadService.cs" />
  95 + <Compile Include="Services\YammerAuthProviderInstance.cs" />
  96 + </ItemGroup>
  97 + <ItemGroup>
  98 + <ProjectReference Include="..\Api.Contracts\Api.Contracts.csproj">
  99 + <Project>{465D9510-43D7-4C51-8B11-1FB57D6A7C9D}</Project>
  100 + <Name>Api.Contracts</Name>
  101 + </ProjectReference>
  102 + <ProjectReference Include="..\Core\Core.csproj">
  103 + <Project>{1F902AAD-9A34-4530-A3E3-62B0F31A38A5}</Project>
  104 + <Name>Core</Name>
  105 + </ProjectReference>
  106 + <ProjectReference Include="..\Data\Data.csproj">
  107 + <Project>{B40B33E8-B802-4384-8F22-F7670B060566}</Project>
  108 + <Name>Data</Name>
  109 + </ProjectReference>
  110 + </ItemGroup>
  111 + <ItemGroup>
  112 + <Resource Include="Templates\facebook.htm" />
  113 + </ItemGroup>
  114 + <ItemGroup>
  115 + <None Include="packages.config" />
  116 + </ItemGroup>
  117 + <ItemGroup>
  118 + <Folder Include="Handlers\" />
  119 + </ItemGroup>
  120 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  121 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  122 + Other similar extension points exist, see Microsoft.Common.targets.
  123 + <Target Name="BeforeBuild">
  124 + </Target>
  125 + <Target Name="AfterBuild">
  126 + </Target>
  127 + -->
125 128 </Project>
56 Api.Implementations/HandlerMapper.cs
... ... @@ -0,0 +1,56 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +
  4 +namespace Api.Implementations
  5 +{
  6 + public interface IHandlerMapper
  7 + {
  8 + /// <summary>
  9 + ///
  10 + /// </summary>
  11 + /// <typeparam name="T">Request DTO</typeparam>
  12 + /// <typeparam name="TU">Response DTO</typeparam>
  13 + void Register(Type dtoType, Func<object, object> handler);
  14 +
  15 +
  16 + object Publish<T>(T dto);
  17 + }
  18 +
  19 + public class HandlerMapper : IHandlerMapper
  20 + {
  21 + private readonly Dictionary<string, Func<object, object>> _handlers;
  22 +
  23 + public HandlerMapper()
  24 + {
  25 + _handlers = new Dictionary<string, Func<object, object>>();
  26 + }
  27 + /// <summary>
  28 + ///
  29 + /// </summary>
  30 + /// <typeparam name="T">Request DTO</typeparam>
  31 + /// <typeparam name="TU">Response DTO</typeparam>
  32 + public void Register(Type dtoType, Func<object, object> handler)
  33 + {
  34 +
  35 + var handlerKey = GetKey(dtoType);
  36 +
  37 + _handlers.Add(handlerKey, o => handler(o));
  38 + }
  39 +
  40 + public object Publish<T>(T dto)
  41 + {
  42 + var handlerKey = GetKey(default(T));
  43 + if (_handlers.ContainsKey(handlerKey))
  44 + {
  45 + var func = _handlers[handlerKey];
  46 + return func(dto);
  47 + }
  48 + throw new InvalidOperationException();
  49 + }
  50 +
  51 + private static string GetKey(object o)
  52 + {
  53 + return o.GetType().FullName;
  54 + }
  55 + }
  56 +}
37 Api.Implementations/Registration.cs
... ... @@ -1,21 +1,33 @@
1   -using System.Collections.Generic;
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Reflection;
  5 +using Api.Contracts.DTO;
2 6 using Api.Contracts.Repositories;
3 7 using Api.Contracts.Services;
4 8 using Api.Implementations.Repositories;
5 9 using Api.Implementations.Services;
6 10 using Core;
  11 +using Data;
7 12 using Funq;
8 13
9 14 namespace Api.Implementations
10 15 {
11 16 public class Registration : IFunqRegistrationModule
12 17 {
  18 + public IHandlerMapper Mapper;
  19 +
  20 +
13 21 public void RegisterDependencies(Container container)
14 22 {
15 23 container.Register<IAuthConsumerService>(c => new AuthConsumerService(c.Resolve<IUserTokenRepository>(),
16 24 c.Resolve<IServiceProviderRepository>(),
17 25 c.Resolve<IAuthProviderFactory>()));
18 26
  27 + container.Register<IUserBreadService>(
  28 + c => new UserBreadService(c.Resolve<IAccountUserRepository>(), c.Resolve<IUserRepository>()));
  29 +
  30 +
19 31 container.Register<IApplicationAuthenticationService>(
20 32 c => new ApplicationAuthenticationService(c.Resolve<IApplicationRepository>()));
21 33
@@ -27,6 +39,29 @@ public void RegisterDependencies(Container container)
27 39 });
28 40
29 41 RegisterRepositories(container);
  42 +
  43 +
  44 + // Mapper.Register<RegisterAccountUserRequest, User>(UserBreadService.RegisterUserForAccount);
  45 +
  46 + }
  47 +
  48 + private void MapDtos(Container container)
  49 + {
  50 + var instance = container.Resolve<IUserBreadService>();
  51 +
  52 + var methods = instance.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance);
  53 +
  54 + var methodsWithOneParam = methods.Where(m => m.GetParameters().Length > 0);
  55 +
  56 + foreach (var methodInfo in methodsWithOneParam)
  57 + {
  58 + var paraminfos =
  59 + methodInfo.GetParameters();
  60 +
  61 + var paramType = paraminfos[0].GetType();
  62 + var m = methodInfo;
  63 + Mapper.Register(paramType, (t)=> m.Invoke(instance, new[] {t}));
  64 + }
30 65 }
31 66
32 67 private static void RegisterRepositories(Container container)
14 Api.Implementations/Repositories/AccountApplicationRepository.cs
@@ -22,5 +22,19 @@ public IEnumerable<AccountApplication> GetForAccount(int accountId)
22 22 AccountId = accountId
23 23 }));
24 24 }
  25 +
  26 + public Account GetForApplication(int applicationId)
  27 + {
  28 + return ConnectionProvider.ExecuteQuery(c =>
  29 + {
  30 + var accountApplication = c.Where<AccountApplication>(new
  31 + {
  32 + ApplicationId = applicationId
  33 + }).FirstOrDefault();
  34 +
  35 + return c.Where<Account>(new {Id = accountApplication.AccountId}).FirstOrDefault();
  36 + });
  37 +
  38 + }
25 39 }
26 40 }
12 Api.Implementations/Repositories/AccountUserRepository.cs
@@ -12,13 +12,13 @@ public AccountUserRepository(IDataConnectionProvider connectionProvider) : base(
12 12 {
13 13 }
14 14
15   - public IEnumerable<AccountUser> GetForAccount(int accountId)
  15 + public IEnumerable<User> GetForAccount(int accountId)
16 16 {
17   - return ConnectionProvider.ExecuteQuery(c =>
18   - c.Where<AccountUser>(new
19   - {
20   - AccountId = accountId
21   - }));
  17 + return ConnectionProvider.ExecuteQuery(c => c.Select<User>(
  18 + string.Format(
  19 + "Select * from User u INNER JOIN AccountUser au ON u.Id=au.UserId where " +
  20 + " au.AccountId={0}",
  21 + accountId)));
22 22 }
23 23 }
24 24 }
20 Api.Implementations/Repositories/BaseDataItemRepository.cs
@@ -84,30 +84,28 @@ public IEnumerable<T> GetValues(int page, int pagesize)
84 84
85 85 public T GetById(int id)
86 86 {
87   - using (var dbConn = ConnectionProvider.OpenConnection())
88   - using (var dbCmd = dbConn.CreateCommand())
  87 + using (var dbConn = ConnectionProvider.OpenConnection())
89 88 {
90   - var items = dbCmd.Where<T>(new { Id = id });
  89 + var items = dbConn.Where<T>(new { Id = id });
91 90 return items.FirstOrDefault();
92 91 }
93 92 }
94 93
95 94 public IEnumerable<T> GetValues(Status status, int page, int pagesize)
96 95 {
97   - using (var dbConn = ConnectionProvider.OpenConnection())
98   - using (var dbCmd = dbConn.CreateCommand())
99   - {
100   - var items = dbCmd.Where<T>(new { Status = (int)status });
101   - return items.Select(i => i).OrderBy(c => c.Created).Skip((page - 1) * pagesize).Take(pagesize);
102   - }
  96 + return ConnectionProvider.ExecuteQuery(conn =>
  97 + {
  98 + var items = conn.Where<T>(new { Status = (int)status });
  99 + return items.Select(i => i).OrderBy(c => c.Created).Skip((page - 1)*pagesize).Take(pagesize);
  100 + });
103 101 }
104 102
105   - public static T GetById(int id, IDbCommand cmd = null)
  103 + public static T GetById(int id, IDbConnection cmd = null)
106 104 {
107 105 return cmd.SingleWhere<T>("Id", id);
108 106 }
109 107
110   - protected long AddGlobal(IDbCommand cmd, T dataitem)
  108 + protected long AddGlobal(IDbConnection cmd, T dataitem)
111 109 {
112 110 var item = GetById(dataitem.Id, cmd);
113 111 if (item != null)
57 Api.Implementations/Services/ApplicationBreadService.cs
... ... @@ -0,0 +1,57 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Text;
  5 +using Api.Contracts.DTO;
  6 +using Api.Contracts.Repositories;
  7 +using Api.Contracts.Services;
  8 +using Data;
  9 +
  10 +namespace Api.Implementations.Services
  11 +{
  12 + public class ApplicationBreadService : IApplicationBreadService
  13 + {
  14 + private readonly IAccountApplicationRepository _accountApplicationRepository;
  15 + private readonly IApplicationRepository _applicationRepository;
  16 +
  17 + public ApplicationBreadService(IAccountApplicationRepository accountApplicationRepository)
  18 + {
  19 + _accountApplicationRepository = accountApplicationRepository;
  20 + }
  21 +
  22 + public Application GetApplication(GetApplicationRequest request)
  23 + {
  24 + return request.Application;
  25 + }
  26 +
  27 + public Application RegisterApplicationForAccount(AddApplicationRequest request)
  28 + {
  29 + throw new NotImplementedException();
  30 + }
  31 +
  32 + public ApplicationService RegisterServiceForApplication(AddApplicationServiceRequest request)
  33 + {
  34 + throw new NotImplementedException();
  35 + }
  36 +
  37 + public EnumerableResponse<ApplicationService> BrowseServicesForApplication(BrowseApplicationServicesRequest request)
  38 + {
  39 + throw new NotImplementedException();
  40 + }
  41 +
  42 + public EnumerableResponse<Application> BrowseApplications(BrowseApplicationsRequest request)
  43 + {
  44 + throw new NotImplementedException();
  45 + }
  46 +
  47 + public void DeleteApplication(DeleteApplicationRequest request)
  48 + {
  49 + throw new NotImplementedException();
  50 + }
  51 +
  52 + public void DeleteApplicationService(DeleteApplicationServiceRequest request)
  53 + {
  54 + throw new NotImplementedException();
  55 + }
  56 + }
  57 +}
45 Api.Implementations/Services/UserBreadService.cs
... ... @@ -0,0 +1,45 @@
  1 +using System.Linq;
  2 +using Api.Contracts.DTO;
  3 +using Api.Contracts.Repositories;
  4 +using Api.Contracts.Services;
  5 +using Data;
  6 +
  7 +namespace Api.Implementations.Services
  8 +{
  9 + public class UserBreadService : IUserBreadService
  10 + {
  11 + private readonly IAccountUserRepository _accountUserRepository;
  12 + private readonly IUserRepository _userRepository;
  13 +
  14 +
  15 + public UserBreadService(IAccountUserRepository accountUserRepository,
  16 + IUserRepository userRepository)
  17 + {
  18 + _accountUserRepository = accountUserRepository;
  19 + _userRepository = userRepository;
  20 + }
  21 +
  22 + public EnumerableResponse<User> BrowseUsersForAccount(BrowseAccountUsersRequest request)
  23 + {
  24 + return new EnumerableResponse<User>
  25 + {
  26 + Items = _accountUserRepository.GetForAccount(request.Account.Id).ToList()
  27 + };
  28 + }
  29 +
  30 + public User RegisterUserForAccount(RegisterAccountUserRequest request)
  31 + {
  32 + _accountUserRepository.Add(new AccountUser
  33 + {
  34 + UserId = request.User.Id,
  35 + AccountId = request.Account.Id
  36 + });
  37 + return request.User;
  38 + }
  39 +
  40 + public User GetUser(GetUserRequest request)
  41 + {
  42 + return _userRepository.GetById(request.Id);
  43 + }
  44 + }
  45 +}
31 Api.RestHandlers/Api.RestHandlers.csproj
@@ -68,15 +68,28 @@
68 68 </ItemGroup>
69 69 <ItemGroup>
70 70 <Compile Include="ApiRegistration.cs" />
71   - <Compile Include="EmptyExampleHandler.cs" />
72   - <Compile Include="GetRegistrationHtmlHandler.cs" />
73   - <Compile Include="GetServiceTokenForPrincipalIdHandler.cs" />
74   - <Compile Include="GetSupportedServicesHandler.cs" />
75   - <Compile Include="IsRegisteredForServiceHandler.cs" />
  71 + <Compile Include="Handlers\AddApplicationRequestHandler.cs" />
  72 + <Compile Include="Handlers\AddApplicationServiceRequestHandler.cs" />
  73 + <Compile Include="Handlers\BrowseAccountUsersRequestHandler.cs" />
  74 + <Compile Include="Handlers\BrowseApplicationServicesRequestHandler.cs" />
  75 + <Compile Include="Handlers\BrowseApplicationsRequestHandler.cs" />
  76 + <Compile Include="Handlers\DeleteApplicationRequestHandler.cs" />
  77 + <Compile Include="Handlers\DeleteApplicationServiceRequestHandler.cs" />
  78 + <Compile Include="Handlers\EmptyExampleHandler.cs" />
  79 + <Compile Include="Handlers\GetApplicationRequestHandler.cs" />
  80 + <Compile Include="Handlers\GetRegistrationHtmlHandler.cs" />
  81 + <Compile Include="Handlers\GetServiceTokenForPrincipalIdHandler.cs" />
  82 + <Compile Include="Handlers\GetSupportedServicesHandler.cs" />
  83 + <Compile Include="Handlers\GetUserRequestHandler.cs" />
  84 + <Compile Include="Handlers\IsRegisteredForServiceHandler.cs" />
  85 + <Compile Include="Handlers\RegisterAccountRequestHandler.cs" />
  86 + <Compile Include="Handlers\RegisterAccountUserRequestHandler.cs" />
  87 + <Compile Include="Handlers\RegisterServiceProviderRequestHandler.cs" />
  88 + <Compile Include="Handlers\RegisterServiceTokenHandler.cs" />
76 89 <Compile Include="Properties\AssemblyInfo.cs" />
77   - <Compile Include="RegisterServiceProviderRequestHandler.cs" />
78   - <Compile Include="RegisterServiceTokenHandler.cs" />
79 90 <Compile Include="RequiresAppRegistrationAttribute.cs" />
  91 + <Compile Include="Validators\ApplicationRequestValidator.cs" />
  92 + <Compile Include="Validators\GetSupportedServicesRequestValidator.cs" />
80 93 </ItemGroup>
81 94 <ItemGroup>
82 95 <None Include="packages.config" />
@@ -86,6 +99,10 @@
86 99 <Project>{465D9510-43D7-4C51-8B11-1FB57D6A7C9D}</Project>
87 100 <Name>Api.Contracts</Name>
88 101 </ProjectReference>
  102 + <ProjectReference Include="..\Api.Implementations\Api.Implementations.csproj">
  103 + <Project>{6B511690-28B0-400D-97EA-8EE7B3046F91}</Project>
  104 + <Name>Api.Implementations</Name>
  105 + </ProjectReference>
89 106 <ProjectReference Include="..\Data\Data.csproj">
90 107 <Project>{B40B33E8-B802-4384-8F22-F7670B060566}</Project>
91 108 <Name>Data</Name>
21 Api.RestHandlers/Handlers/AddApplicationRequestHandler.cs
... ... @@ -0,0 +1,21 @@
  1 +using Api.Contracts.DTO;
  2 +using Api.Contracts.Services;
  3 +using ServiceStack.ServiceInterface;
  4 +
  5 +namespace Api.RestHandlers.Handlers
  6 +{
  7 + public class AddApplicationRequestHandler : RestServiceBase<AddApplicationRequest>
  8 + {
  9 + private readonly IApplicationBreadService _applicationBreadService;
  10 +
  11 + public AddApplicationRequestHandler(IApplicationBreadService applicationBreadService)
  12 + {
  13 + _applicationBreadService = applicationBreadService;
  14 + }
  15 +
  16 + public override object OnPut(AddApplicationRequest request)
  17 + {
  18 + return _applicationBreadService.RegisterApplicationForAccount(request);
  19 + }
  20 + }
  21 +}
22 Api.RestHandlers/Handlers/AddApplicationServiceRequestHandler.cs
... ... @@ -0,0 +1,22 @@
  1 +using Api.Contracts.DTO;
  2 +using Api.Contracts.Services;
  3 +using ServiceStack.ServiceInterface;
  4 +
  5 +namespace Api.RestHandlers.Handlers
  6 +{
  7 + [RequiresAppRegistration(Priority = -1, ApplyTo = ApplyTo.All)]
  8 + public class AddApplicationServiceRequestHandler : RestServiceBase<AddApplicationServiceRequest>
  9 + {
  10 + private readonly IApplicationBreadService _applicationBreadService;
  11 +
  12 + public AddApplicationServiceRequestHandler(IApplicationBreadService applicationBreadService)
  13 + {
  14 + _applicationBreadService = applicationBreadService;
  15 + }
  16 +
  17 + public override object OnPut(AddApplicationServiceRequest request)
  18 + {
  19 + return _applicationBreadService.RegisterServiceForApplication(request);
  20 + }
  21 + }
  22 +}
21 Api.RestHandlers/Handlers/BrowseAccountUsersRequestHandler.cs
... ... @@ -0,0 +1,21 @@
  1 +using Api.Contracts.DTO;
  2 +using Api.Contracts.Services;
  3 +using ServiceStack.ServiceInterface;
  4 +
  5 +namespace Api.RestHandlers.Handlers
  6 +{
  7 + public class BrowseAccountUsersRequestHandler : RestServiceBase<BrowseAccountUsersRequest>
  8 + {
  9 + private readonly IUserBreadService _userBreadService;
  10 +
  11 + public BrowseAccountUsersRequestHandler(IUserBreadService userBreadService)
  12 + {
  13 + _userBreadService = userBreadService;
  14 + }
  15 +
  16 + public override object OnGet(BrowseAccountUsersRequest request)
  17 + {
  18 + return _userBreadService.BrowseUsersForAccount(request);
  19 + }
  20 + }
  21 +}
21 Api.RestHandlers/Handlers/BrowseApplicationServicesRequestHandler.cs
... ... @@ -0,0 +1,21 @@
  1 +using Api.Contracts.DTO;
  2 +using Api.Contracts.Services;
  3 +using ServiceStack.ServiceInterface;
  4 +
  5 +namespace Api.RestHandlers.Handlers
  6 +{
  7 + public class BrowseApplicationServicesRequestHandler : RestServiceBase<BrowseApplicationServicesRequest>
  8 + {
  9 + private readonly IApplicationBreadService _applicationBreadService;
  10 +
  11 + public BrowseApplicationServicesRequestHandler(IApplicationBreadService applicationBreadService)
  12 + {
  13 + _applicationBreadService = applicationBreadService;
  14 + }
  15 +
  16 + public override object OnGet(BrowseApplicationServicesRequest request)
  17 + {
  18 + return _applicationBreadService.BrowseServicesForApplication(request);
  19 + }
  20 + }
  21 +}
21 Api.RestHandlers/Handlers/BrowseApplicationsRequestHandler.cs
... ... @@ -0,0 +1,21 @@
  1 +using Api.Contracts.DTO;
  2 +using Api.Contracts.Services;