This repository has been archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #404 from dotnet/rynowak/fix-formatting
Fix line endings and formatting
- Loading branch information
Showing
109 changed files
with
4,181 additions
and
4,176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* text=auto | ||
*.cs text=auto diff=csharp | ||
*.sh text eol=lf | ||
*.sln text eol=crlf |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<clear /> | ||
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" /> | ||
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> | ||
<add key="featherhttp" value="https://f.feedz.io/davidfowl/featherhttp/nuget/index.json" /> | ||
<add key="bedrockframework" value="https://f.feedz.io/davidfowl/bedrockframework/nuget/index.json" /> | ||
</packageSources> | ||
</configuration> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<clear /> | ||
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" /> | ||
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> | ||
<add key="featherhttp" value="https://f.feedz.io/davidfowl/featherhttp/nuget/index.json" /> | ||
<add key="bedrockframework" value="https://f.feedz.io/davidfowl/bedrockframework/nuget/index.json" /> | ||
</packageSources> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "orders", "orders\orders.csproj", "{206BCB04-37DC-48EC-B3D5-566C53291AEF}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "products", "products\products.csproj", "{B9DB838D-2DCA-468E-A707-075A9FAE960F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "store", "store\store.csproj", "{7D053D12-7A1E-44B2-87AB-44DC391D2C13}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x64.Build.0 = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x86.Build.0 = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x64.ActiveCfg = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x64.Build.0 = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x86.ActiveCfg = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x86.Build.0 = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x64.Build.0 = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x86.Build.0 = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x64.ActiveCfg = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x64.Build.0 = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x86.ActiveCfg = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x86.Build.0 = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x64.Build.0 = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x86.Build.0 = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x64.ActiveCfg = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x64.Build.0 = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x86.ActiveCfg = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "orders", "orders\orders.csproj", "{206BCB04-37DC-48EC-B3D5-566C53291AEF}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "products", "products\products.csproj", "{B9DB838D-2DCA-468E-A707-075A9FAE960F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "store", "store\store.csproj", "{7D053D12-7A1E-44B2-87AB-44DC391D2C13}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x64.Build.0 = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Debug|x86.Build.0 = Debug|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x64.ActiveCfg = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x64.Build.0 = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x86.ActiveCfg = Release|Any CPU | ||
{206BCB04-37DC-48EC-B3D5-566C53291AEF}.Release|x86.Build.0 = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x64.Build.0 = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Debug|x86.Build.0 = Debug|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x64.ActiveCfg = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x64.Build.0 = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x86.ActiveCfg = Release|Any CPU | ||
{B9DB838D-2DCA-468E-A707-075A9FAE960F}.Release|x86.Build.0 = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x64.Build.0 = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Debug|x86.Build.0 = Debug|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x64.ActiveCfg = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x64.Build.0 = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x86.ActiveCfg = Release|Any CPU | ||
{7D053D12-7A1E-44B2-87AB-44DC391D2C13}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,82 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Dapr; | ||
using Dapr.Client; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace orders.Controllers | ||
{ | ||
[ApiController] | ||
public class OrdersController : ControllerBase | ||
{ | ||
[Topic("orderplaced")] | ||
[HttpPost("orderplaced")] | ||
public async Task PlaceOrder(Order order, [FromServices] DaprClient dapr, [FromServices] ILogger<OrdersController> logger) | ||
{ | ||
logger.LogInformation("Got order {OrderId} for product {ProductId}", order.OrderId, order.ProductId); | ||
|
||
var state = await dapr.GetStateEntryAsync<InventoryState>("default", order.ProductId.ToString()); | ||
if (state.Value == null || state.Value.Remaining < -10) | ||
{ | ||
// For demo purposes, assume we have 5 of these in stock :) | ||
state.Value = new InventoryState() { Remaining = 5, }; | ||
} | ||
|
||
state.Value.Remaining--; | ||
await state.SaveAsync(); | ||
|
||
logger.LogInformation("Updated inventory for product {ProductId} to {Inventory}", order.ProductId, state.Value.Remaining); | ||
|
||
OrderConfirmation confirmation; | ||
if (state.Value.Remaining >= 0) | ||
{ | ||
confirmation = new OrderConfirmation() | ||
{ | ||
OrderId = order.OrderId, | ||
Confirmed = true, | ||
DeliveryDate = DateTime.Now.AddYears(1), | ||
RemainingCount = state.Value.Remaining, | ||
}; | ||
} | ||
else | ||
{ | ||
confirmation = new OrderConfirmation() | ||
{ | ||
OrderId = order.OrderId, | ||
Confirmed = false, | ||
BackorderCount = -1 * state.Value.Remaining, | ||
}; | ||
} | ||
|
||
await dapr.PublishEventAsync("orderprocessed", confirmation); | ||
|
||
logger.LogInformation("Sent confirmation for order {OrderId}", order.OrderId); | ||
|
||
} | ||
} | ||
|
||
public class Order | ||
{ | ||
public string OrderId { get; set; } = default!; | ||
public int ProductId { get; set ; } | ||
} | ||
|
||
public class InventoryState | ||
{ | ||
public int Remaining { get; set; } | ||
} | ||
|
||
public class OrderConfirmation | ||
{ | ||
public string OrderId { get; set; } = default!; | ||
|
||
public DateTime? DeliveryDate { get; set; } | ||
|
||
public bool Confirmed { get; set; } | ||
|
||
public int BackorderCount { get; set; } | ||
|
||
public int RemainingCount { get; set; } | ||
} | ||
} | ||
using System; | ||
using System.Threading.Tasks; | ||
using Dapr; | ||
using Dapr.Client; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace orders.Controllers | ||
{ | ||
[ApiController] | ||
public class OrdersController : ControllerBase | ||
{ | ||
[Topic("orderplaced")] | ||
[HttpPost("orderplaced")] | ||
public async Task PlaceOrder(Order order, [FromServices] DaprClient dapr, [FromServices] ILogger<OrdersController> logger) | ||
{ | ||
logger.LogInformation("Got order {OrderId} for product {ProductId}", order.OrderId, order.ProductId); | ||
|
||
var state = await dapr.GetStateEntryAsync<InventoryState>("default", order.ProductId.ToString()); | ||
if (state.Value == null || state.Value.Remaining < -10) | ||
{ | ||
// For demo purposes, assume we have 5 of these in stock :) | ||
state.Value = new InventoryState() { Remaining = 5, }; | ||
} | ||
|
||
state.Value.Remaining--; | ||
await state.SaveAsync(); | ||
|
||
logger.LogInformation("Updated inventory for product {ProductId} to {Inventory}", order.ProductId, state.Value.Remaining); | ||
|
||
OrderConfirmation confirmation; | ||
if (state.Value.Remaining >= 0) | ||
{ | ||
confirmation = new OrderConfirmation() | ||
{ | ||
OrderId = order.OrderId, | ||
Confirmed = true, | ||
DeliveryDate = DateTime.Now.AddYears(1), | ||
RemainingCount = state.Value.Remaining, | ||
}; | ||
} | ||
else | ||
{ | ||
confirmation = new OrderConfirmation() | ||
{ | ||
OrderId = order.OrderId, | ||
Confirmed = false, | ||
BackorderCount = -1 * state.Value.Remaining, | ||
}; | ||
} | ||
|
||
await dapr.PublishEventAsync("orderprocessed", confirmation); | ||
|
||
logger.LogInformation("Sent confirmation for order {OrderId}", order.OrderId); | ||
|
||
} | ||
} | ||
|
||
public class Order | ||
{ | ||
public string OrderId { get; set; } = default!; | ||
public int ProductId { get; set ; } | ||
} | ||
|
||
public class InventoryState | ||
{ | ||
public int Remaining { get; set; } | ||
} | ||
|
||
public class OrderConfirmation | ||
{ | ||
public string OrderId { get; set; } = default!; | ||
|
||
public DateTime? DeliveryDate { get; set; } | ||
|
||
public bool Confirmed { get; set; } | ||
|
||
public int BackorderCount { get; set; } | ||
|
||
public int RemainingCount { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
using System; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace orders | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} | ||
using System; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace orders | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} |
Oops, something went wrong.