Continued to work on the update student handler

This commit is contained in:
2019-04-29 13:54:10 -04:00
parent 8cacaa36ce
commit 9f2b9bcff9
10 changed files with 114 additions and 24 deletions

View File

@@ -9,6 +9,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="JsonNet.PrivateSettersContractResolvers.Source" Version="0.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MediatR" Version="6.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.All" />

View File

@@ -43,7 +43,8 @@ namespace BrightGlimmer.Api.Controllers
[HttpPut]
public async Task<ActionResult> Update([FromBody]UpdateStudentCommand command)
{
var student = await mediator.Send(command);
return new JsonResult(student);
}
}
}

View File

@@ -24,7 +24,12 @@ namespace BrightGlimmer.Api
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new PrivateSetterContractResolver()
});
services.AddMediatR();
services.AddMediatR(typeof(Cqrs.Cqrs).Assembly); // Registers handlers in services project