Skip to content

Commit

Permalink
Bug fixed.
Browse files Browse the repository at this point in the history
Using Newtonsoft.Json instead of System.System.Text.Json which is the default since 3.1.
The latter doesn't convert strings to ints automatically. This was the cause of the issue.

https://github.com/dotnet/corefx/issues/39473
  • Loading branch information
andy-a-o committed Jan 7, 2020
1 parent 63e6540 commit e5278b3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/EventManagement.Web/EventManagement.Web.csproj
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Losol.Communication.Sms.Mock" Version="$(LosolCommunicationLibraryVersion)" />
<PackageReference Include="Mapster" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
<PackageReference Include="Sentry.AspNetCore" Version="2.0.0-beta7" />
<PackageReference Include="Stripe.net" Version="[16.4.0]" />
Expand Down
Expand Up @@ -73,8 +73,12 @@ public static class ServiceCollectionExtensions
public static void ConfigureMvc(
this IServiceCollection services)
{
services.AddControllersWithViews();
services.AddRazorPages()
services
.AddControllersWithViews()
.AddNewtonsoftJson();

services
.AddRazorPages()
.AddRazorPagesOptions(options =>
{
options.Conventions.AuthorizeFolder("/Account/Manage");
Expand Down Expand Up @@ -126,7 +130,7 @@ public static void AddSiteConfig(this IServiceCollection services, IConfiguratio

// TODO: Change to feature manager later
var featureConfig = Configuration.GetSection("FeatureManagement").Get<FeatureManagement>();

}

public static void AddEmailServices(this IServiceCollection services,
Expand Down
2 changes: 0 additions & 2 deletions src/EventManagement.Web/Startup.cs
Expand Up @@ -4,8 +4,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand Down
Expand Up @@ -21,7 +21,7 @@ public OrdersControllerTest(CustomWebApplicationFactory<Startup> factory)
}

[Fact]
public async Task Should_Update_Existing_Order()
public async Task Should_Update_Existing_Order_Using_Strings()
{
var client = this.factory.CreateClient();
await client.LogInAsSuperAdminAsync();
Expand All @@ -43,8 +43,8 @@ public async Task Should_Update_Existing_Order()
{
new
{
id = product.Entity.ProductId,
quantity = 1
id = product.Entity.ProductId.ToString(),
quantity = "1"
}
}
}), Encoding.UTF8, "application/json"));
Expand Down

0 comments on commit e5278b3

Please sign in to comment.