Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP.NET Core sample #59

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions demos/asp-net-core/Divergent.CompositionGateway.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Divergent.CompositionGateway", "Divergent.CompositionGateway\Divergent.CompositionGateway.csproj", "{C0E4CD4F-657A-4872-969C-D97768636BDA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ITOps", "ITOps", "{DB3EFAF6-6B45-48ED-BCB9-5F44FAB30CF9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ITOps.ViewModelComposition.Gateway", "ITOps.ViewModelComposition.Gateway\ITOps.ViewModelComposition.Gateway.csproj", "{1B2BC5FF-3F95-4429-8AE1-5AC6C99B689A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ITOps.ViewModelComposition", "ITOps.ViewModelComposition\ITOps.ViewModelComposition.csproj", "{10268718-D7A5-4F3B-A91C-A991DD93FAF6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sales", "Sales", "{C243015C-AEC9-4694-889E-4B57E208FD2A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Divergent.Sales.ViewModelComposition", "Divergent.Sales.ViewModelComposition\Divergent.Sales.ViewModelComposition.csproj", "{7F90C43D-41F7-4243-823C-A05034FEADE2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Divergent.Sales.ViewModelComposition.Events", "Divergent.Sales.ViewModelComposition.Events\Divergent.Sales.ViewModelComposition.Events.csproj", "{5875B01D-5A47-4B08-99B2-48D217F09B30}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shipping", "Shipping", "{9D36D6A4-373C-4CB0-8B54-D15505E2AE91}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Divergent.Shipping.ViewModelComposition", "Divergent.Shipping.ViewModelComposition\Divergent.Shipping.ViewModelComposition.csproj", "{657A5136-DDDE-493F-9247-B2789B3294F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Divergent.Sales.Data", "Divergent.Sales.Data\Divergent.Sales.Data.csproj", "{80F82F7D-3F0A-4316-87CD-49F19DBD5B85}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Divergent.Sales.API.Host", "Divergent.Sales.API.Host\Divergent.Sales.API.Host.csproj", "{DC8ADA37-837C-490F-BDFC-FC8D1001417E}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: "API" should really be cased "Api". Same for Shipping.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said they are the copy of the endpoint used by the exercises. So 👎 to rename them unless we fix them all. Nitpick, API is an acronym thus conventions say it should be uppercase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .NET capitalisation conventions state PascalCasing for any acronym over two letters in length (although the BCL violates that in numerous places). However, it's only a nitpick and I agree that we should fix everything or nothing, so let's leave this as-is for now.

EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Divergent.Shipping.Data", "Divergent.Shipping.Data\Divergent.Shipping.Data.csproj", "{0EFF2E29-829B-4B1C-A7C6-47D63B05F52B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Divergent.Shipping.API.Host", "Divergent.Shipping.API.Host\Divergent.Shipping.API.Host.csproj", "{0059E3AC-0AFA-43F6-B631-200CBB723F94}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ITOps.Json", "ITOps.Json\ITOps.Json.csproj", "{4951C5A4-59D4-4AE1-B74C-B6F667544211}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0E4CD4F-657A-4872-969C-D97768636BDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0E4CD4F-657A-4872-969C-D97768636BDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0E4CD4F-657A-4872-969C-D97768636BDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0E4CD4F-657A-4872-969C-D97768636BDA}.Release|Any CPU.Build.0 = Release|Any CPU
{1B2BC5FF-3F95-4429-8AE1-5AC6C99B689A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B2BC5FF-3F95-4429-8AE1-5AC6C99B689A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B2BC5FF-3F95-4429-8AE1-5AC6C99B689A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B2BC5FF-3F95-4429-8AE1-5AC6C99B689A}.Release|Any CPU.Build.0 = Release|Any CPU
{10268718-D7A5-4F3B-A91C-A991DD93FAF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10268718-D7A5-4F3B-A91C-A991DD93FAF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10268718-D7A5-4F3B-A91C-A991DD93FAF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10268718-D7A5-4F3B-A91C-A991DD93FAF6}.Release|Any CPU.Build.0 = Release|Any CPU
{7F90C43D-41F7-4243-823C-A05034FEADE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F90C43D-41F7-4243-823C-A05034FEADE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F90C43D-41F7-4243-823C-A05034FEADE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F90C43D-41F7-4243-823C-A05034FEADE2}.Release|Any CPU.Build.0 = Release|Any CPU
{5875B01D-5A47-4B08-99B2-48D217F09B30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5875B01D-5A47-4B08-99B2-48D217F09B30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5875B01D-5A47-4B08-99B2-48D217F09B30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5875B01D-5A47-4B08-99B2-48D217F09B30}.Release|Any CPU.Build.0 = Release|Any CPU
{657A5136-DDDE-493F-9247-B2789B3294F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{657A5136-DDDE-493F-9247-B2789B3294F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{657A5136-DDDE-493F-9247-B2789B3294F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{657A5136-DDDE-493F-9247-B2789B3294F3}.Release|Any CPU.Build.0 = Release|Any CPU
{80F82F7D-3F0A-4316-87CD-49F19DBD5B85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80F82F7D-3F0A-4316-87CD-49F19DBD5B85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80F82F7D-3F0A-4316-87CD-49F19DBD5B85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80F82F7D-3F0A-4316-87CD-49F19DBD5B85}.Release|Any CPU.Build.0 = Release|Any CPU
{DC8ADA37-837C-490F-BDFC-FC8D1001417E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC8ADA37-837C-490F-BDFC-FC8D1001417E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC8ADA37-837C-490F-BDFC-FC8D1001417E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC8ADA37-837C-490F-BDFC-FC8D1001417E}.Release|Any CPU.Build.0 = Release|Any CPU
{0EFF2E29-829B-4B1C-A7C6-47D63B05F52B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EFF2E29-829B-4B1C-A7C6-47D63B05F52B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EFF2E29-829B-4B1C-A7C6-47D63B05F52B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EFF2E29-829B-4B1C-A7C6-47D63B05F52B}.Release|Any CPU.Build.0 = Release|Any CPU
{0059E3AC-0AFA-43F6-B631-200CBB723F94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0059E3AC-0AFA-43F6-B631-200CBB723F94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0059E3AC-0AFA-43F6-B631-200CBB723F94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0059E3AC-0AFA-43F6-B631-200CBB723F94}.Release|Any CPU.Build.0 = Release|Any CPU
{4951C5A4-59D4-4AE1-B74C-B6F667544211}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4951C5A4-59D4-4AE1-B74C-B6F667544211}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4951C5A4-59D4-4AE1-B74C-B6F667544211}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4951C5A4-59D4-4AE1-B74C-B6F667544211}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1B2BC5FF-3F95-4429-8AE1-5AC6C99B689A} = {DB3EFAF6-6B45-48ED-BCB9-5F44FAB30CF9}
{10268718-D7A5-4F3B-A91C-A991DD93FAF6} = {DB3EFAF6-6B45-48ED-BCB9-5F44FAB30CF9}
{7F90C43D-41F7-4243-823C-A05034FEADE2} = {C243015C-AEC9-4694-889E-4B57E208FD2A}
{5875B01D-5A47-4B08-99B2-48D217F09B30} = {C243015C-AEC9-4694-889E-4B57E208FD2A}
{657A5136-DDDE-493F-9247-B2789B3294F3} = {9D36D6A4-373C-4CB0-8B54-D15505E2AE91}
{80F82F7D-3F0A-4316-87CD-49F19DBD5B85} = {C243015C-AEC9-4694-889E-4B57E208FD2A}
{DC8ADA37-837C-490F-BDFC-FC8D1001417E} = {C243015C-AEC9-4694-889E-4B57E208FD2A}
{0EFF2E29-829B-4B1C-A7C6-47D63B05F52B} = {9D36D6A4-373C-4CB0-8B54-D15505E2AE91}
{0059E3AC-0AFA-43F6-B631-200CBB723F94} = {9D36D6A4-373C-4CB0-8B54-D15505E2AE91}
{4951C5A4-59D4-4AE1-B74C-B6F667544211} = {DB3EFAF6-6B45-48ED-BCB9-5F44FAB30CF9}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Divergent.Sales.ViewModelComposition.Events\Divergent.Sales.ViewModelComposition.Events.csproj" />
<ProjectReference Include="..\Divergent.Sales.ViewModelComposition\Divergent.Sales.ViewModelComposition.csproj" />
<ProjectReference Include="..\Divergent.Shipping.ViewModelComposition\Divergent.Shipping.ViewModelComposition.csproj" />
<ProjectReference Include="..\ITOps.ViewModelComposition.Gateway\ITOps.ViewModelComposition.Gateway.csproj" />
</ItemGroup>

</Project>
21 changes: 21 additions & 0 deletions demos/asp-net-core/Divergent.CompositionGateway/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Hosting;
using System.IO;

namespace Divergent.CompositionGateway
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();

host.Run();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4457/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Divergent.CompositionGateway": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:4458"
}
}
}
22 changes: 22 additions & 0 deletions demos/asp-net-core/Divergent.CompositionGateway/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using ITOps.ViewModelComposition;
using ITOps.ViewModelComposition.Gateway;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Divergent.CompositionGateway
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddRouting();
services.AddViewModelComposition();
}

public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.RunCompositionGatewayWithDefaultRoutes();
}
}
}
45 changes: 45 additions & 0 deletions demos/asp-net-core/Divergent.Sales.API.Host/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="Divergent.Sales" connectionString="Data Source=c:\temp\composite-ui-asp-net-core-demo-data\divergent.sales.sqlite;Version=3;" providerName="System.Data.SQLite" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<appSettings>
<add key="baseAddress" value="http://localhost:20295/" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>

<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data></configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Divergent.Sales.Data.Context;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web.Http;

namespace Divergent.Sales.API.Host.Controllers
{
[RoutePrefix("api/orders")]
public class OrdersController : ApiController
{
[HttpGet]
public dynamic Get(int id)
{
using (var db = new SalesContext())
{
var order = db.Orders
.Include(o => o.Items)
.Where(o => o.Id == id)
.Select(o => new
{
Number = o.Id,
o.Id,
ItemsCount = o.Items.Count
})
.SingleOrDefault();

return order;
}
}

[HttpGet]
public IEnumerable<dynamic> Get(int pageIndex, int pageSize)
{
using (var db = new SalesContext())
{
var orders = db.Orders
.Include(o => o.Items)
.OrderBy(o => o.Id) //required by SQLite EF
.Skip(pageSize * pageIndex)
.Take(pageSize)
.Select(o => new
{
Number = o.Id,
o.Id,
ItemsCount = o.Items.Count
})
.ToArray();

return orders;
}
}
}
}
Loading