Setup initial solution structure fo application

This commit is contained in:
2019-04-19 22:00:29 +00:00
parent cef4409a7b
commit 4e5142d5ec
9 changed files with 112 additions and 46 deletions

View File

@@ -9,8 +9,14 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="6.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BrightGlimmer.CQRS\BrightGlimmer.Cqrs.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BrightGlimmer.Cqrs.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace BrightGlimmer.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class CourseController : ControllerBase
{
private readonly IMediator mediator;
public CourseController(IMediator mediator)
{
this.mediator = mediator;
}
[HttpGet]
public ActionResult<string> Get()
{
return "";
}
}
}

View File

@@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace BrightGlimmer.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

View File

@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BrightGlimmer.Data;
using MediatR;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
@@ -26,6 +28,8 @@ namespace BrightGlimmer.Api
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddMediatR();
services.AddMediatR(typeof(Cqrs.Cqrs).Assembly); // Registers handlers in Cqrs project
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -44,4 +48,4 @@ namespace BrightGlimmer.Api
app.UseMvc();
}
}
}
}