Skip to content

Commit

Permalink
feat: add product controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikoo-Asadnejad committed May 17, 2024
1 parent c6ad6ae commit ee473f4
Show file tree
Hide file tree
Showing 20 changed files with 1,065 additions and 21 deletions.
6 changes: 0 additions & 6 deletions Src/Product.API/Controllers/ProductController.cs

This file was deleted.

31 changes: 31 additions & 0 deletions Src/Product.API/Controllers/ProductsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using MediatR;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Product.Application.Product.Commands.CreateProduct;
using Product.Application.Product.Queries.GetProduct;

namespace Product.API.Controllers;

[Controller]
public sealed class ProductsController : Controller
{
private readonly IMediator _mediator;
public ProductsController(IMediator mediator)
{
_mediator = mediator;
}

[HttpPost]
public async Task<IActionResult> Product(CreateProductCommand command)
{
await _mediator.Send(command);
return Ok();
}

[HttpGet]
public async Task<IActionResult> Product(GetProductQuery query)
{
var response = await _mediator.Send(query);
return Ok(response);
}
}
5 changes: 5 additions & 0 deletions Src/Product.API/Product.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
Expand All @@ -18,4 +19,8 @@
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Product.Application\Product.Application.csproj" />
</ItemGroup>

</Project>
Binary file modified Src/Product.API/obj/Debug/net7.0/Product.API.assets.cache
Binary file not shown.
Binary file not shown.
134 changes: 133 additions & 1 deletion Src/Product.API/obj/Product.API.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
"projectReferences": {
"/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj": {
"projectPath": "/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj"
}
}
}
},
"warningProperties": {
Expand All @@ -38,6 +42,10 @@
"net7.0": {
"targetAlias": "net7.0",
"dependencies": {
"MediatR": {
"target": "Package",
"version": "[12.1.1, )"
},
"Microsoft.AspNetCore.OpenApi": {
"target": "Package",
"version": "[7.0.1, )"
Expand Down Expand Up @@ -69,6 +77,130 @@
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"
}
}
},
"/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj",
"projectName": "Product.Application",
"projectPath": "/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj",
"packagesPath": "/Users/macbook/.nuget/packages/",
"outputPath": "/Users/macbook/Projects/ProductService/Src/Product.Application/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/macbook/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {
"/Users/macbook/Projects/ProductService/Src/Product.Domain/Product.Domain.csproj": {
"projectPath": "/Users/macbook/Projects/ProductService/Src/Product.Domain/Product.Domain.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"dependencies": {
"FluentValidation": {
"target": "Package",
"version": "[11.9.0, )"
},
"MediatR": {
"target": "Package",
"version": "[12.1.1, )"
},
"Microsoft.Extensions.Hosting.Abstractions": {
"target": "Package",
"version": "[9.0.0-preview.2.24128.5, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"
}
}
},
"/Users/macbook/Projects/ProductService/Src/Product.Domain/Product.Domain.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/macbook/Projects/ProductService/Src/Product.Domain/Product.Domain.csproj",
"projectName": "Product.Domain",
"projectPath": "/Users/macbook/Projects/ProductService/Src/Product.Domain/Product.Domain.csproj",
"packagesPath": "/Users/macbook/.nuget/packages/",
"outputPath": "/Users/macbook/Projects/ProductService/Src/Product.Domain/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/macbook/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"
}
}
}
}
}
9 changes: 9 additions & 0 deletions Src/Product.API/obj/Product.API.csproj.nuget.g.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)system.diagnostics.diagnosticsource/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/System.Diagnostics.DiagnosticSource.targets" Condition="Exists('$(NuGetPackageRoot)system.diagnostics.diagnosticsource/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/System.Diagnostics.DiagnosticSource.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server/6.0.5/build/Microsoft.Extensions.ApiDescription.Server.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server/6.0.5/build/Microsoft.Extensions.ApiDescription.Server.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.primitives/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Primitives.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.primitives/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Primitives.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.dependencyinjection.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.DependencyInjection.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.dependencyinjection.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.DependencyInjection.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.options/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Options.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.options/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Options.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.logging.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.logging.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Logging.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.fileproviders.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.FileProviders.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.fileproviders.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.FileProviders.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.diagnostics.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Diagnostics.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.diagnostics.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Diagnostics.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.configuration.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Configuration.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.configuration.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Configuration.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.hosting.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Hosting.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.hosting.abstractions/9.0.0-preview.2.24128.5/buildTransitive/netcoreapp2.0/Microsoft.Extensions.Hosting.Abstractions.targets')" />
</ImportGroup>
</Project>
Loading

0 comments on commit ee473f4

Please sign in to comment.