In this lesson step we will add controller logic to the Controller projects in the PetStore solution. Controller Implementation projects implement an interface generated by LazyStack to service Lambda events. Controller Implementation methods implement business logic, usually calling the repository project to perform CRUDL operations on persistent data. It is not unusual for Controller Implementation methods to call other libraries required by your application.
dotnet new classlib -o Controllers\OrderControllerImpl
MacOS/Linus: dotnet new classlib -o Controllers/OrderControllerImpl
Windows: dotnet sln add Controllers\OrderControllerImpl\OrderControllerImpl.csproj
MacOS/Linux: dotnet sln add Controllers/OrderControllerImpl/OrderControllerImpl.csproj
You now have a OrderControllerImpl C# Class Lib project in your solution.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\PetStoreRepo\PetStoreRepo.csproj" />
<ProjectReference Include="..\OrderController\OrderController.csproj" />
</ItemGroup>
</Project>
dotnet build
The solution compiles successfully.
dotnet new classlib -o Controllers\PetControllerImpl
MacOS/Linus: dotnet new classlib -o Controllers/PetControllerImpl
Windows: dotnet sln add Controllers\PetControllerImpl\PetControllerImpl.csproj
MacOS/Linux: dotnet sln add Controllers/PetControllerImpl/PetControllerImpl.csproj
You now have a PetControllerImpl C# Class Lib project in your solution.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\PetStoreRepo\PetStoreRepo.csproj" />
<ProjectReference Include="..\OrderController\OrderController.csproj" />
</ItemGroup>
</Project>
Note the TargetFramework is "netcoreapp3.1".
dotnet build
The solution compiles successfully.
In this step we implemented the PetStoreRepo project by: