Skip to content

Commit

Permalink
Add Church.Host.Core project
Browse files Browse the repository at this point in the history
  • Loading branch information
davevans committed Jul 9, 2014
1 parent e887fd4 commit b6ca2f7
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,4 @@ $RECYCLE.BIN/

# Mac desktop service store files
.DS_Store
/src/Church/packages/EntityFramework.6.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChurchService.cs" />
<Compile Include="IChurchService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repository\CoreContext.cs" />
<Compile Include="Repository\ChurchMappings.cs" />
Expand Down
22 changes: 22 additions & 0 deletions src/Church/Church.Components.Core/ChurchService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Church.Components.Core
{
public class ChurchService : IChurchService
{
private Repository.ICoreRepository _coreRepository;
public ChurchService(Repository.ICoreRepository coreRepository)
{
_coreRepository = coreRepository;
}

public Model.Core.Church GetById(int churchId)
{
return _coreRepository.GetById(churchId);
}
}
}
13 changes: 13 additions & 0 deletions src/Church/Church.Components.Core/IChurchService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Church.Components.Core
{
public interface IChurchService
{
Church.Model.Core.Church GetById(int churchId);
}
}
6 changes: 6 additions & 0 deletions src/Church/Church.Host.Core/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
104 changes: 104 additions & 0 deletions src/Church/Church.Host.Core/Church.Host.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1F70684F-BDA5-4926-A73C-11A6BCB386D0}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Church.Host.Core</RootNamespace>
<AssemblyName>Church.Host.Core</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Owin">
<HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Host.HttpListener">
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Hosting">
<HintPath>..\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.0\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.0\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http.Owin">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.0\lib\net45\System.Web.Http.Owin.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\ChurchController.cs" />
<Compile Include="HttpConfiguration.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Startup.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Church.Common\Church.Common.csproj">
<Project>{5ed93ccb-eff1-4d29-be10-433a8431cc27}</Project>
<Name>Church.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Church.Components.Core\Church.Components.Core.csproj">
<Project>{dc8504ad-f791-4c54-83ca-7727cc1d7e2a}</Project>
<Name>Church.Components.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Church.Model\Church.Model.csproj">
<Project>{3563e57a-a00f-4d0b-8e02-099d3315d954}</Project>
<Name>Church.Model</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
19 changes: 19 additions & 0 deletions src/Church/Church.Host.Core/Controllers/ChurchController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Church.Model.Core;

namespace Church.Host.Core.Controllers
{
public class ChurchController : ApiController
{
[HttpGet]
public Church.Model.Core.Church Get(int id)
{
return new Church.Model.Core.Church { Id = 1, Name = "Erko", TimeZone = new Church.Model.Core.TimeZone { Id = 1, Name = "Whatevs" } };
}
}
}
52 changes: 52 additions & 0 deletions src/Church/Church.Host.Core/HttpConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace Church.Host.Core
{
public class HttpConfiguration : System.Web.Http.HttpConfiguration
{
public HttpConfiguration()
{
ConfigureRoutes();
ConfigureJsonSerialization();
}

void ConfigureRoutes()
{
Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}

void ConfigureJsonSerialization()
{
Formatters.Add(new BrowserJsonFormatter());
}
}

public class BrowserJsonFormatter : JsonMediaTypeFormatter
{
public BrowserJsonFormatter()
{
this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
this.SerializerSettings.Formatting = Formatting.Indented;
this.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
}

public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType)
{
base.SetDefaultContentHeaders(type, headers, mediaType);
headers.ContentType = new MediaTypeHeaderValue("application/json");
}
}
}
24 changes: 24 additions & 0 deletions src/Church/Church.Host.Core/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Owin.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Church.Host.Core
{
class Program
{
static void Main(string[] args)
{
string baseAddress = "http://localhost:9000/";

using (WebApp.Start<Startup>(url: baseAddress))
{

Console.WriteLine("Listening at {0}.", baseAddress);
Console.ReadLine();
}
}
}
}
36 changes: 36 additions & 0 deletions src/Church/Church.Host.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Church.Host.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Church.Host.Core")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("57608103-1157-478b-a6de-54bcf0747e27")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
19 changes: 19 additions & 0 deletions src/Church/Church.Host.Core/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace Church.Host.Core
{
public class Startup
{
public void Configuration(IAppBuilder appBuilder)
{
var httpConfig = new Church.Host.Core.HttpConfiguration();
appBuilder.UseWebApi(httpConfig);
}
}
}
12 changes: 12 additions & 0 deletions src/Church/Church.Host.Core/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.0" targetFramework="net451" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.0" targetFramework="net451" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.0" targetFramework="net451" />
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.0" targetFramework="net451" />
<package id="Microsoft.Owin" version="2.0.2" targetFramework="net451" />
<package id="Microsoft.Owin.Host.HttpListener" version="2.0.2" targetFramework="net451" />
<package id="Microsoft.Owin.Hosting" version="2.0.2" targetFramework="net451" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net451" />
<package id="Owin" version="1.0" targetFramework="net451" />
</packages>
6 changes: 6 additions & 0 deletions src/Church/Church.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Church.Components.Core", "C
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Church.Common", "Church.Common\Church.Common.csproj", "{5ED93CCB-EFF1-4D29-BE10-433A8431CC27}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Church.Host.Core", "Church.Host.Core\Church.Host.Core.csproj", "{1F70684F-BDA5-4926-A73C-11A6BCB386D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -35,6 +37,10 @@ Global
{5ED93CCB-EFF1-4D29-BE10-433A8431CC27}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5ED93CCB-EFF1-4D29-BE10-433A8431CC27}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5ED93CCB-EFF1-4D29-BE10-433A8431CC27}.Release|Any CPU.Build.0 = Release|Any CPU
{1F70684F-BDA5-4926-A73C-11A6BCB386D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F70684F-BDA5-4926-A73C-11A6BCB386D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F70684F-BDA5-4926-A73C-11A6BCB386D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F70684F-BDA5-4926-A73C-11A6BCB386D0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions src/Church/packages/repositories.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<repositories>
<repository path="..\Church.Common\packages.config" />
<repository path="..\Church.Components.Core\packages.config" />
<repository path="..\Church.Host.Core\packages.config" />
</repositories>

0 comments on commit b6ca2f7

Please sign in to comment.