(refactor): reimplementing docker compose
This commit is contained in:
parent
750263d466
commit
4b858008a9
3
.gitignore
vendored
3
.gitignore
vendored
@ -230,3 +230,6 @@ _Pvt_Extensions
|
|||||||
|
|
||||||
# FAKE - F# Make
|
# FAKE - F# Make
|
||||||
.fake/
|
.fake/
|
||||||
|
|
||||||
|
# Custom
|
||||||
|
webapi/docker-compose
|
||||||
@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": 2,
|
"locale": 2,
|
||||||
"slug": "predefinit",
|
"slug": "predefinita",
|
||||||
"text": "Categoria predefinita"
|
"text": "Categoria predefinita"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -23,7 +23,3 @@
|
|||||||
**/values.dev.yaml
|
**/values.dev.yaml
|
||||||
LICENSE
|
LICENSE
|
||||||
README.md
|
README.md
|
||||||
|
|
||||||
**/node_modules
|
|
||||||
**/npm-debug.log
|
|
||||||
build
|
|
||||||
@ -7,7 +7,13 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Extensions\Extensions.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -7,9 +7,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Core.Enumerations {
|
namespace Core.Enumerations {
|
||||||
public class Errors : Enumeration {
|
public class Errors : Enumeration {
|
||||||
public static Errors NullOrWhiteSpace = new(0, "is null or white space");
|
public static Errors Generic = new(0, "generic error occured");
|
||||||
public static Errors WrongOrNotManaged = new(1, "is wrong or not managed");
|
|
||||||
public static Errors NullOrEmpty = new(2, "is null or empty");
|
public static Errors NullOrWhiteSpace = new(1, "is null or white space");
|
||||||
|
public static Errors WrongOrNotManaged = new(2, "is wrong or not managed");
|
||||||
|
public static Errors NullOrEmpty = new(3, "is null or empty");
|
||||||
|
|
||||||
private Errors(int id, string displayName) : base(id, displayName) { }
|
private Errors(int id, string displayName) : base(id, displayName) { }
|
||||||
}
|
}
|
||||||
|
|||||||
42
webapi/Core/Middlewares/ErrorHandlerMiddleware.cs
Normal file
42
webapi/Core/Middlewares/ErrorHandlerMiddleware.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using Core.Enumerations;
|
||||||
|
using ExtensionMethods;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace Core.Middlewares {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// https://jasonwatmore.com/post/2022/01/17/net-6-global-error-handler-tutorial-with-example
|
||||||
|
/// </summary>
|
||||||
|
public class ErrorHandlerMiddleware {
|
||||||
|
private readonly ILogger<ErrorHandlerMiddleware> _logger;
|
||||||
|
private readonly RequestDelegate _next;
|
||||||
|
|
||||||
|
public ErrorHandlerMiddleware(
|
||||||
|
ILogger<ErrorHandlerMiddleware> logger,
|
||||||
|
RequestDelegate next) {
|
||||||
|
_logger = logger;
|
||||||
|
_next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(HttpContext context) {
|
||||||
|
try {
|
||||||
|
await _next(context);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Unhandled error");
|
||||||
|
|
||||||
|
var response = context.Response;
|
||||||
|
response.ContentType = "application/json";
|
||||||
|
response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||||
|
|
||||||
|
await response.WriteAsync(new ProblemDetails {
|
||||||
|
Title = Errors.Generic.Name,
|
||||||
|
Detail = $"{Errors.Generic.Id}"
|
||||||
|
}.ToJson());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,7 +12,7 @@ namespace DataProviders.Buckets {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SpecificBucketDataProviderBase : BucketDataProviderBase {
|
public abstract class SpecificBucketDataProviderBase : BucketDataProviderBase {
|
||||||
|
|
||||||
private readonly string _bucketName;
|
private readonly string _bucketName;
|
||||||
|
|
||||||
|
|||||||
22
webapi/ReverseProxy/Dockerfile
Normal file
22
webapi/ReverseProxy/Dockerfile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
EXPOSE 443
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["ReverseProxy/ReverseProxy.csproj", "ReverseProxy/"]
|
||||||
|
RUN dotnet restore "ReverseProxy/ReverseProxy.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/ReverseProxy"
|
||||||
|
RUN dotnet build "ReverseProxy.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "ReverseProxy.csproj" -c Release -o /app/publish
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "ReverseProxy.dll"]
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
@ -10,12 +10,12 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"ReverseProxy": {
|
"ReverseProxy": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"applicationUrl": "https://localhost:7174;http://localhost:5178",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"applicationUrl": "https://localhost:7174;http://localhost:5178",
|
||||||
|
"dotnetRunMessages": true
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -23,6 +23,13 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||||
|
"publishAllPorts": true,
|
||||||
|
"useSSL": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,9 +4,13 @@
|
|||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||||
|
<UserSecretsId>a3a6c5ea-054e-4e38-b7a4-800796fa0dd3</UserSecretsId>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
|
||||||
<PackageReference Include="Yarp.ReverseProxy" Version="1.1.0" />
|
<PackageReference Include="Yarp.ReverseProxy" Version="1.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -25,6 +25,12 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"route3": {
|
"route3": {
|
||||||
|
"ClusterId": "cluster1",
|
||||||
|
"Match": {
|
||||||
|
"Path": "swagger/{**catchall}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"route4": {
|
||||||
"ClusterId": "cluster2",
|
"ClusterId": "cluster2",
|
||||||
"Match": {
|
"Match": {
|
||||||
"Path": "{**catchall}"
|
"Path": "{**catchall}"
|
||||||
@ -35,7 +41,7 @@
|
|||||||
"cluster1": {
|
"cluster1": {
|
||||||
"Destinations": {
|
"Destinations": {
|
||||||
"destination1": {
|
"destination1": {
|
||||||
"Address": "https://localhost:7151/"
|
"Address": "http://weatherforecast:5133/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -15,8 +15,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataProviders", "DataProviders\DataProviders.csproj", "{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataProviders", "DataProviders\DataProviders.csproj", "{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{38A28E4B-319A-44B0-AA9B-54F3F0362317}"
|
|
||||||
EndProject
|
|
||||||
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "ClientApp", "ClientApp\ClientApp.njsproj", "{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}"
|
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "ClientApp", "ClientApp\ClientApp.njsproj", "{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extensions", "Extensions\Extensions.csproj", "{94A44D75-4AE2-4F1A-A7E9-821710B19F93}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extensions", "Extensions\Extensions.csproj", "{94A44D75-4AE2-4F1A-A7E9-821710B19F93}"
|
||||||
@ -33,6 +31,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FileSecurityService", "Serv
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReverseProxy", "ReverseProxy\ReverseProxy.csproj", "{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReverseProxy", "ReverseProxy\ReverseProxy.csproj", "{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -59,10 +59,6 @@ Global
|
|||||||
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{13EDFAD4-5D8B-4879-96F7-D896265FB0DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{38A28E4B-319A-44B0-AA9B-54F3F0362317}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{8531F7E2-07D6-4EC5-B3E6-316BBF4499E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@ -91,6 +87,10 @@ Global
|
|||||||
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.Build.0 = Release|Any CPU
|
{281F43C5-3B40-4DA6-B32B-8E8BC39D3DA3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7FC6F0BA-2DCB-4B53-A3B3-61CEEF42B9D0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -6,38 +6,38 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using WeatherForecast.Models.Requests;
|
using WeatherForecast.Models.Requests;
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class AuthenticationController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IAuthenticationService _authenticationService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AllowAnonymous]
|
/// <param name="authenticationService"></param>
|
||||||
[ApiController]
|
public AuthenticationController(
|
||||||
[Route("api/[controller]")]
|
IAuthenticationService authenticationService
|
||||||
public class AuthenticationController : ControllerBase {
|
) {
|
||||||
|
_authenticationService = authenticationService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IAuthenticationService _authenticationService;
|
/// <summary>
|
||||||
|
///
|
||||||
/// <summary>
|
/// </summary>
|
||||||
///
|
/// <param name="siteId"></param>
|
||||||
/// </summary>
|
/// <param name="requestData"></param>
|
||||||
/// <param name="authenticationService"></param>
|
/// <returns></returns>
|
||||||
public AuthenticationController(
|
[HttpPost("{siteId}")]
|
||||||
IAuthenticationService authenticationService
|
public IActionResult Post([FromRoute] Guid siteId, [FromBody] AuthenticationRequestModel requestData) {
|
||||||
) {
|
var result = _authenticationService.Post(siteId, requestData);
|
||||||
_authenticationService = authenticationService;
|
return result.ToActionResult();
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="requestData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("{siteId}")]
|
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromBody] AuthenticationRequestModel requestData) {
|
|
||||||
var result = _authenticationService.Post(siteId, requestData);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,86 +6,86 @@ using DomainResults.Mvc;
|
|||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
using WeatherForecast.Models.Requests;
|
using WeatherForecast.Models.Requests;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize(Policy = "")]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class BlogItemController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IBlogItemService _blogItemService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="blogItemService"></param>
|
||||||
[ApiController]
|
public BlogItemController(
|
||||||
[Route("api/[controller]")]
|
IBlogItemService blogItemService
|
||||||
public class BlogItemController : ControllerBase {
|
) {
|
||||||
|
_blogItemService = blogItemService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IBlogItemService _blogItemService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="requestData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("{siteId}")]
|
||||||
|
public IActionResult Post([FromRoute] Guid siteId, [FromBody] BlogItemRequestModel requestData) {
|
||||||
|
var result = _blogItemService.Post(siteId, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Returns full object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="blogItemService"></param>
|
/// <returns></returns>
|
||||||
public BlogItemController(
|
[HttpGet("{siteId}/{blogId}")]
|
||||||
IBlogItemService blogItemService
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid blogId) {
|
||||||
) {
|
var result = _blogItemService.Get(siteId, blogId);
|
||||||
_blogItemService = blogItemService;
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="requestData"></param>
|
/// <param name="slug"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{siteId}")]
|
[AllowAnonymous]
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromBody] BlogItemRequestModel requestData) {
|
[HttpGet("{siteId}")]
|
||||||
var result = _blogItemService.Post(siteId, requestData);
|
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
||||||
return result.ToActionResult();
|
var result = _blogItemService.GetSlug(siteId, slug);
|
||||||
}
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns full object
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <param name="siteId"></param>
|
||||||
[HttpGet("{siteId}/{blogId}")]
|
/// <param name="blogId"></param>
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid blogId) {
|
/// <param name="requestData"></param>
|
||||||
var result = _blogItemService.Get(siteId, blogId);
|
/// <returns></returns>
|
||||||
return result.ToActionResult();
|
[HttpPut("{siteId}/{blogId}")]
|
||||||
}
|
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid blogId, [FromBody] BlogItemRequestModel requestData) {
|
||||||
|
var result = _blogItemService.Update(siteId, blogId, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="slug"></param>
|
/// <param name="blogId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{siteId}")]
|
[HttpDelete("{siteId}/{blogId}")]
|
||||||
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid blogId) {
|
||||||
var result = _blogItemService.GetSlug(siteId, slug);
|
var result = _blogItemService.Delete(siteId, blogId);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="blogId"></param>
|
|
||||||
/// <param name="requestData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut("{siteId}/{blogId}")]
|
|
||||||
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid blogId, [FromBody] BlogItemRequestModel requestData) {
|
|
||||||
var result = _blogItemService.Update(siteId, blogId, requestData);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="blogId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{siteId}/{blogId}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid blogId) {
|
|
||||||
var result = _blogItemService.Delete(siteId, blogId);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace WeatherForecast.Controllers;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AllowAnonymous]
|
[Authorize(Policy = "")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class BlogItemsController : ControllerBase {
|
public class BlogItemsController : ControllerBase {
|
||||||
@ -37,6 +37,7 @@ public class BlogItemsController : ControllerBase {
|
|||||||
/// <param name="itemsPerPage"></param>
|
/// <param name="itemsPerPage"></param>
|
||||||
/// <param name="locale"></param>
|
/// <param name="locale"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
[HttpGet("{siteId}")]
|
[HttpGet("{siteId}")]
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale) {
|
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale) {
|
||||||
var result = _blogItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText);
|
var result = _blogItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText);
|
||||||
|
|||||||
@ -6,86 +6,86 @@ using DomainResults.Mvc;
|
|||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
using WeatherForecast.Models.Requests;
|
using WeatherForecast.Models.Requests;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class CategoryItemController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly ICategoryItemService _categoryItemService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="categoryItemService"></param>
|
||||||
[ApiController]
|
public CategoryItemController(
|
||||||
[Route("api/[controller]")]
|
ICategoryItemService categoryItemService) {
|
||||||
public class CategoryItemController : ControllerBase {
|
_categoryItemService = categoryItemService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly ICategoryItemService _categoryItemService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="requestData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("{siteId}")]
|
||||||
|
public IActionResult Post([FromRoute] Guid siteId, [FromBody] CategoryItemRequestModel requestData) {
|
||||||
|
var result = _categoryItemService.Post(siteId, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Returns full object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="categoryItemService"></param>
|
/// <param name="siteId"></param>
|
||||||
public CategoryItemController(
|
/// <param name="categoryId"></param>
|
||||||
ICategoryItemService categoryItemService) {
|
/// <returns></returns>
|
||||||
_categoryItemService = categoryItemService;
|
[HttpGet("{siteId}/{categoryId}")]
|
||||||
}
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
|
||||||
|
var result = _categoryItemService.Get(siteId, categoryId);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="requestData"></param>
|
/// <param name="slug"></param>
|
||||||
/// <returns></returns>
|
[AllowAnonymous]
|
||||||
[HttpPost("{siteId}")]
|
[HttpGet("{siteId}")]
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromBody] CategoryItemRequestModel requestData) {
|
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
||||||
var result = _categoryItemService.Post(siteId, requestData);
|
var result = _categoryItemService.GetSlug(siteId, slug);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns full object
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="categoryId"></param>
|
/// <param name="categoryId"></param>
|
||||||
/// <returns></returns>
|
/// <param name="requestData"></param>
|
||||||
[HttpGet("{siteId}/{categoryId}")]
|
/// <returns></returns>
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
|
[HttpPut("{siteId}/{categoryId}")]
|
||||||
var result = _categoryItemService.Get(siteId, categoryId);
|
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid categoryId, [FromBody] CategoryItemRequestModel requestData) {
|
||||||
return result.ToActionResult();
|
var result = _categoryItemService.Update(siteId, categoryId, requestData);
|
||||||
}
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="slug"></param>
|
/// <param name="categoryId"></param>
|
||||||
[AllowAnonymous]
|
/// <returns></returns>
|
||||||
[HttpGet("{siteId}")]
|
[HttpDelete("{siteId}/{categoryId}")]
|
||||||
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
|
||||||
var result = _categoryItemService.GetSlug(siteId, slug);
|
var result = _categoryItemService.Delete(siteId, categoryId);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="categoryId"></param>
|
|
||||||
/// <param name="requestData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut("{siteId}/{categoryId}")]
|
|
||||||
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid categoryId, [FromBody] CategoryItemRequestModel requestData) {
|
|
||||||
var result = _categoryItemService.Update(siteId, categoryId, requestData);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="categoryId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{siteId}/{categoryId}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
|
|
||||||
var result = _categoryItemService.Delete(siteId, categoryId);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,50 +5,50 @@ using DomainResults.Mvc;
|
|||||||
|
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class CategoryItemsController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly ICategoryItemsService _categoryItemsService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="categoryItemsService"></param>
|
||||||
[ApiController]
|
public CategoryItemsController(
|
||||||
[Route("api/[controller]")]
|
ICategoryItemsService categoryItemsService
|
||||||
public class CategoryItemsController : ControllerBase {
|
) {
|
||||||
|
_categoryItemsService = categoryItemsService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly ICategoryItemsService _categoryItemsService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="locale"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}")]
|
||||||
|
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] string? locale) {
|
||||||
|
var result = _categoryItemsService.Get(siteId, locale);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="categoryItemsService"></param>
|
/// <param name="siteId"></param>
|
||||||
public CategoryItemsController(
|
/// <returns></returns>
|
||||||
ICategoryItemsService categoryItemsService
|
[AllowAnonymous]
|
||||||
) {
|
[HttpDelete("{siteId}")]
|
||||||
_categoryItemsService = categoryItemsService;
|
public IActionResult Delete([FromRoute] Guid siteId) {
|
||||||
}
|
var result = _categoryItemsService.Delete(siteId);
|
||||||
|
return result.ToActionResult();
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="locale"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{siteId}")]
|
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] string? locale) {
|
|
||||||
var result = _categoryItemsService.Get(siteId, locale);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[AllowAnonymous]
|
|
||||||
[HttpDelete("{siteId}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId) {
|
|
||||||
var result = _categoryItemsService.Delete(siteId);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,72 +4,72 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class FileController : Controller {
|
||||||
|
|
||||||
|
private readonly IFileService _fileService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="fileService"></param>
|
||||||
[AllowAnonymous]
|
public FileController(
|
||||||
[Route("api/[controller]")]
|
IFileService fileService
|
||||||
public class FileController : Controller {
|
) {
|
||||||
|
_fileService = fileService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IFileService _fileService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("{siteId}/{userId}")]
|
||||||
|
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, IFormFile file) {
|
||||||
|
var result = _fileService.Post(siteId, userId, file);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// https://www.c-sharpcorner.com/article/fileresult-in-asp-net-core-mvc2/
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileService"></param>
|
/// <param name="siteId"></param>
|
||||||
public FileController(
|
/// <param name="userid"></param>
|
||||||
IFileService fileService
|
/// <param name="fileId"></param>
|
||||||
) {
|
/// <returns></returns>
|
||||||
_fileService = fileService;
|
[HttpGet("{siteId}/{userId}/{fileId}")]
|
||||||
}
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userid, [FromRoute] Guid fileId) {
|
||||||
|
var (file, result) = _fileService.Get(siteId, userid, fileId);
|
||||||
|
|
||||||
/// <summary>
|
if (!result.IsSuccess || file == null)
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <param name="file"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("{siteId}/{userId}")]
|
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, IFormFile file) {
|
|
||||||
var result = _fileService.Post(siteId, userId, file);
|
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
var stream = new MemoryStream(file.Bytes);
|
||||||
/// https://www.c-sharpcorner.com/article/fileresult-in-asp-net-core-mvc2/
|
return new FileStreamResult(stream, file.ContentType) {
|
||||||
/// </summary>
|
FileDownloadName = file.Name
|
||||||
/// <param name="siteId"></param>
|
};
|
||||||
/// <param name="userid"></param>
|
}
|
||||||
/// <param name="fileId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{siteId}/{userId}/{fileId}")]
|
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userid, [FromRoute] Guid fileId) {
|
|
||||||
var (file, result) = _fileService.Get(siteId, userid, fileId);
|
|
||||||
|
|
||||||
if (!result.IsSuccess || file == null)
|
/// <summary>
|
||||||
return result.ToActionResult();
|
///
|
||||||
|
/// </summary>
|
||||||
var stream = new MemoryStream(file.Bytes);
|
/// <param name="siteId"></param>
|
||||||
return new FileStreamResult(stream, file.ContentType) {
|
/// <param name="userId"></param>
|
||||||
FileDownloadName = file.Name
|
/// <param name="fileId"></param>
|
||||||
};
|
/// <returns></returns>
|
||||||
}
|
[HttpDelete("{siteId}/{userId}/{fileId}")]
|
||||||
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] Guid fileId) {
|
||||||
/// <summary>
|
var result = _fileService.Delete(siteId, userId, fileId);
|
||||||
///
|
return result.ToActionResult();
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <param name="fileId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{siteId}/{userId}/{fileId}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] Guid fileId) {
|
|
||||||
var result = _fileService.Delete(siteId, userId, fileId);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,52 +3,52 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class FilesController : Controller {
|
||||||
|
|
||||||
|
private readonly IFilesService _filesService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="filesService"></param>
|
||||||
[AllowAnonymous]
|
public FilesController(
|
||||||
[Route("api/[controller]")]
|
IFilesService filesService
|
||||||
public class FilesController : Controller {
|
) {
|
||||||
|
_filesService = filesService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IFilesService _filesService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("{siteId}/{userId}")]
|
||||||
|
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, List<IFormFile> file) {
|
||||||
|
var result = _filesService.Post(siteId, userId, file);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filesService"></param>
|
/// <param name="siteId"></param>
|
||||||
public FilesController(
|
/// <param name="userId"></param>
|
||||||
IFilesService filesService
|
/// <returns></returns>
|
||||||
) {
|
|
||||||
_filesService = filesService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
[HttpDelete("{siteId}/{userId}")]
|
||||||
///
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) {
|
||||||
/// </summary>
|
var result = _filesService.Delete(siteId, userId);
|
||||||
/// <param name="siteId"></param>
|
return result.ToActionResult();
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <param name="file"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("{siteId}/{userId}")]
|
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, List<IFormFile> file) {
|
|
||||||
var result = _filesService.Post(siteId, userId, file);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
|
|
||||||
[HttpDelete("{siteId}/{userId}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) {
|
|
||||||
var result = _filesService.Delete(siteId, userId);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,49 +4,48 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
using DomainResults.Mvc;
|
using DomainResults.Mvc;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ImageController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IImageService _imageService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AllowAnonymous]
|
/// <param name="imgeService"></param>
|
||||||
[Route("api/[controller]")]
|
public ImageController(
|
||||||
[ApiController]
|
IImageService imgeService
|
||||||
public class ImageController : ControllerBase {
|
) {
|
||||||
|
_imageService = imgeService;
|
||||||
private readonly IImageService _imageService;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="imgeService"></param>
|
|
||||||
public ImageController(
|
|
||||||
IImageService imgeService
|
|
||||||
) {
|
|
||||||
_imageService = imgeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="width"></param>
|
|
||||||
/// <param name="height"></param>
|
|
||||||
/// <param name="imageId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{siteId}/{width}x{height}/{imageId}")]
|
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] int width, [FromRoute] int height, [FromRoute] Guid imageId) {
|
|
||||||
|
|
||||||
var (file, result) = _imageService.Get(siteId, width, height, imageId);
|
|
||||||
|
|
||||||
if (!result.IsSuccess || file == null)
|
|
||||||
return result.ToActionResult();
|
|
||||||
|
|
||||||
var stream = new MemoryStream(file.Bytes);
|
|
||||||
return new FileStreamResult(stream, file.ContentType) {
|
|
||||||
FileDownloadName = file.Name
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="width"></param>
|
||||||
|
/// <param name="height"></param>
|
||||||
|
/// <param name="imageId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}/{width}x{height}/{imageId}")]
|
||||||
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] int width, [FromRoute] int height, [FromRoute] Guid imageId) {
|
||||||
|
|
||||||
|
var (file, result) = _imageService.Get(siteId, width, height, imageId);
|
||||||
|
|
||||||
|
if (!result.IsSuccess || file == null)
|
||||||
|
return result.ToActionResult();
|
||||||
|
|
||||||
|
var stream = new MemoryStream(file.Bytes);
|
||||||
|
return new FileStreamResult(stream, file.ContentType) {
|
||||||
|
FileDownloadName = file.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,34 +5,35 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using WeatherForecast.Models.Requests;
|
using WeatherForecast.Models.Requests;
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class PasswordController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IPasswordService _passwordService;
|
||||||
|
|
||||||
|
public PasswordController(
|
||||||
|
IPasswordService passwordService
|
||||||
|
) {
|
||||||
|
_passwordService = passwordService;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="siteId"></param>
|
||||||
[Route("api/[controller]")]
|
/// <param name="userId"></param>
|
||||||
[ApiController]
|
/// <param name="requestData"></param>
|
||||||
public class PasswordController : ControllerBase {
|
/// <returns></returns>
|
||||||
|
[HttpPost("{siteId}/{userId}")]
|
||||||
private readonly IPasswordService _passwordService;
|
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromBody] PasswordRequestModel requestData) {
|
||||||
|
var result = _passwordService.Post(siteId, userId, requestData);
|
||||||
public PasswordController(
|
return result.ToActionResult();
|
||||||
IPasswordService passwordService
|
|
||||||
) {
|
|
||||||
_passwordService = passwordService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <param name="requestData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("{siteId}/{userId}")]
|
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromBody] PasswordRequestModel requestData) {
|
|
||||||
var result = _passwordService.Post(siteId, userId, requestData);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,78 +6,78 @@ using DomainResults.Mvc;
|
|||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
using WeatherForecast.Models.Requests;
|
using WeatherForecast.Models.Requests;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ShopCartItemController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IShopCartItemService _shopCartItemService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="shopCartItemService"></param>
|
||||||
[AllowAnonymous]
|
public ShopCartItemController(
|
||||||
[Route("api/[controller]")]
|
IShopCartItemService shopCartItemService
|
||||||
public class ShopCartItemController : ControllerBase {
|
) {
|
||||||
|
_shopCartItemService = shopCartItemService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IShopCartItemService _shopCartItemService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="sku"></param>
|
||||||
|
/// <param name="requestData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("{siteId}/{userId}/{sku}")]
|
||||||
|
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] ShopCartItemRequestModel requestData) {
|
||||||
|
var result = _shopCartItemService.Post(siteId, userId, sku, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="shopCartItemService"></param>
|
/// <returns></returns>
|
||||||
public ShopCartItemController(
|
[HttpGet("{siteId}/{userId}/{sku}")]
|
||||||
IShopCartItemService shopCartItemService
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromQuery] string? locale) {
|
||||||
) {
|
var result = _shopCartItemService.Get(siteId, userId, sku, locale);
|
||||||
_shopCartItemService = shopCartItemService;
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="sku"></param>
|
/// <param name="sku"></param>
|
||||||
/// <param name="requestData"></param>
|
/// <param name="requestData"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{siteId}/{userId}/{sku}")]
|
[HttpPut("{siteId}/{userId}/{sku}")]
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] ShopCartItemRequestModel requestData) {
|
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] ShopCartItemRequestModel requestData) {
|
||||||
var result = _shopCartItemService.Post(siteId, userId, sku, requestData);
|
var result = _shopCartItemService.Update(siteId, userId, sku, requestData);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <param name="siteId"></param>
|
||||||
[HttpGet("{siteId}/{userId}/{sku}")]
|
/// <param name="userId"></param>
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromQuery] string? locale) {
|
/// <param name="sku"></param>
|
||||||
var result = _shopCartItemService.Get(siteId, userId, sku, locale);
|
/// <returns></returns>
|
||||||
return result.ToActionResult();
|
[HttpDelete("{siteId}/{userId}/{sku}")]
|
||||||
}
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku) {
|
||||||
|
var result = _shopCartItemService.Delete(siteId, userId, sku);
|
||||||
/// <summary>
|
return result.ToActionResult();
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <param name="sku"></param>
|
|
||||||
/// <param name="requestData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut("{siteId}/{userId}/{sku}")]
|
|
||||||
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] ShopCartItemRequestModel requestData) {
|
|
||||||
var result = _shopCartItemService.Update(siteId, userId, sku, requestData);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <param name="sku"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{siteId}/{userId}/{sku}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku) {
|
|
||||||
var result = _shopCartItemService.Delete(siteId, userId, sku);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,50 +5,49 @@ using DomainResults.Mvc;
|
|||||||
|
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ShopCartItemsController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IShopCartItemsService _shopCartItemsService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="shopCartItemsService"></param>
|
||||||
[AllowAnonymous]
|
public ShopCartItemsController(
|
||||||
[Route("api/[controller]")]
|
IShopCartItemsService shopCartItemsService
|
||||||
public class ShopCartItemsController : ControllerBase {
|
) {
|
||||||
|
_shopCartItemsService = shopCartItemsService;
|
||||||
private readonly IShopCartItemsService _shopCartItemsService;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="shopCartItemsService"></param>
|
|
||||||
public ShopCartItemsController(
|
|
||||||
IShopCartItemsService shopCartItemsService
|
|
||||||
) {
|
|
||||||
_shopCartItemsService = shopCartItemsService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{siteId}/{userId}")]
|
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromQuery] string? locale) {
|
|
||||||
var result = _shopCartItemsService.Get(siteId, userId, locale);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="userId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{siteId}/{userId}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) {
|
|
||||||
var result = _shopCartItemsService.Delete(siteId, userId);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}/{userId}")]
|
||||||
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromQuery] string? locale) {
|
||||||
|
var result = _shopCartItemsService.Get(siteId, userId, locale);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("{siteId}/{userId}")]
|
||||||
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) {
|
||||||
|
var result = _shopCartItemsService.Delete(siteId, userId);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,89 +6,89 @@ using DomainResults.Mvc;
|
|||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
using WeatherForecast.Models.Requests;
|
using WeatherForecast.Models.Requests;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ShopItemController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IShopItemService _shopItemService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="shopItemService"></param>
|
||||||
[ApiController]
|
public ShopItemController(
|
||||||
[Route("api/[controller]")]
|
IShopItemService shopItemService
|
||||||
public class ShopItemController : ControllerBase {
|
) {
|
||||||
|
_shopItemService = shopItemService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IShopItemService _shopItemService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="sku"></param>
|
||||||
|
/// <param name="requestData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("{siteId}/{sku}")]
|
||||||
|
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] string sku, [FromBody] ShopItemRequestModel requestData) {
|
||||||
|
var result = _shopItemService.Post(siteId, sku, requestData);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Returns full object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="shopItemService"></param>
|
/// <param name="siteId"></param>
|
||||||
public ShopItemController(
|
/// <param name="sku"></param>
|
||||||
IShopItemService shopItemService
|
/// <returns></returns>
|
||||||
) {
|
[HttpGet("{siteId}/{sku}")]
|
||||||
_shopItemService = shopItemService;
|
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] string sku) {
|
||||||
}
|
var result = _shopItemService.Get(siteId, sku);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="sku"></param>
|
/// <param name="slug"></param>
|
||||||
/// <param name="requestData"></param>
|
/// <returns></returns>
|
||||||
/// <returns></returns>
|
[AllowAnonymous]
|
||||||
[HttpPost("{siteId}/{sku}")]
|
[HttpGet("{siteId}")]
|
||||||
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] string sku, [FromBody] ShopItemRequestModel requestData) {
|
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
||||||
var result = _shopItemService.Post(siteId, sku, requestData);
|
var result = _shopItemService.GetSlug(siteId, slug);
|
||||||
return result.ToActionResult();
|
return result.ToActionResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns full object
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="sku"></param>
|
/// <param name="sku"></param>
|
||||||
/// <returns></returns>
|
/// <param name="requestData"></param>
|
||||||
[HttpGet("{siteId}/{sku}")]
|
/// <returns></returns>
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] string sku) {
|
[HttpPut("{siteId}/{sku}")]
|
||||||
var result = _shopItemService.Get(siteId, sku);
|
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] string sku, [FromBody] ShopItemRequestModel requestData) {
|
||||||
return result.ToActionResult();
|
var result = _shopItemService.Update(siteId, sku, requestData);
|
||||||
}
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="siteId"></param>
|
/// <param name="siteId"></param>
|
||||||
/// <param name="slug"></param>
|
/// <param name="sku"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[HttpDelete("{siteId}/{sku}")]
|
||||||
[HttpGet("{siteId}")]
|
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] string sku) {
|
||||||
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
|
var result = _shopItemService.Delete(siteId, sku);
|
||||||
var result = _shopItemService.GetSlug(siteId, slug);
|
return result.ToActionResult();
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="sku"></param>
|
|
||||||
/// <param name="requestData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut("{siteId}/{sku}")]
|
|
||||||
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] string sku, [FromBody] ShopItemRequestModel requestData) {
|
|
||||||
var result = _shopItemService.Update(siteId, sku, requestData);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="sku"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{siteId}/{sku}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] string sku) {
|
|
||||||
var result = _shopItemService.Delete(siteId, sku);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,53 +5,52 @@ using DomainResults.Mvc;
|
|||||||
|
|
||||||
using WeatherForecast.Services;
|
using WeatherForecast.Services;
|
||||||
|
|
||||||
namespace WeatherForecast.Controllers {
|
namespace WeatherForecast.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ShopItemsController : ControllerBase {
|
||||||
|
|
||||||
|
private readonly IShopItemsService _shopItemsService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
/// <param name="shopCatalogService"></param>
|
||||||
[ApiController]
|
public ShopItemsController(
|
||||||
[Route("api/[controller]")]
|
IShopItemsService shopCatalogService
|
||||||
public class ShopItemsController : ControllerBase {
|
) {
|
||||||
|
_shopItemsService = shopCatalogService;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IShopItemsService _shopItemsService;
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="siteId"></param>
|
||||||
|
/// <param name="category"></param>
|
||||||
|
/// <param name="currentPage"></param>
|
||||||
|
/// <param name="itemsPerPage"></param>
|
||||||
|
/// <param name="locale"></param>
|
||||||
|
/// <param name="searchText"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{siteId}")]
|
||||||
|
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale, [FromQuery] string? searchText) {
|
||||||
|
var result = _shopItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText);
|
||||||
|
return result.ToActionResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="shopCatalogService"></param>
|
/// <param name="siteId"></param>
|
||||||
public ShopItemsController(
|
/// <returns></returns>
|
||||||
IShopItemsService shopCatalogService
|
[HttpDelete("{siteId}")]
|
||||||
) {
|
public IActionResult Delete([FromRoute] Guid siteId) {
|
||||||
_shopItemsService = shopCatalogService;
|
var result = _shopItemsService.Delete(siteId);
|
||||||
}
|
return result.ToActionResult();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <param name="category"></param>
|
|
||||||
/// <param name="currentPage"></param>
|
|
||||||
/// <param name="itemsPerPage"></param>
|
|
||||||
/// <param name="locale"></param>
|
|
||||||
/// <param name="searchText"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{siteId}")]
|
|
||||||
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale, [FromQuery] string? searchText) {
|
|
||||||
var result = _shopItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="siteId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{siteId}")]
|
|
||||||
public IActionResult Delete([FromRoute] Guid siteId) {
|
|
||||||
var result = _shopItemsService.Delete(siteId);
|
|
||||||
return result.ToActionResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,7 +8,13 @@ EXPOSE 443
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY ["WeatherForecast/WeatherForecast.csproj", "WeatherForecast/"]
|
COPY ["WeatherForecast/WeatherForecast.csproj", "WeatherForecast/"]
|
||||||
|
COPY ["Services/FileSecurityService/FileSecurityService.csproj", "Services/FileSecurityService/"]
|
||||||
|
COPY ["Extensions/Extensions.csproj", "Extensions/"]
|
||||||
COPY ["Core/Core.csproj", "Core/"]
|
COPY ["Core/Core.csproj", "Core/"]
|
||||||
|
COPY ["Services/ImageProvider/ImageProvider.csproj", "Services/ImageProvider/"]
|
||||||
|
COPY ["DataProviders/DataProviders.csproj", "DataProviders/"]
|
||||||
|
COPY ["Services/JWTService/JWTService.csproj", "Services/JWTService/"]
|
||||||
|
COPY ["Services/HashService/HashService.csproj", "Services/HashService/"]
|
||||||
RUN dotnet restore "WeatherForecast/WeatherForecast.csproj"
|
RUN dotnet restore "WeatherForecast/WeatherForecast.csproj"
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR "/src/WeatherForecast"
|
WORKDIR "/src/WeatherForecast"
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"WeatherForecast": {
|
"WeatherForecast": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"launchBrowser": true,
|
"launchBrowser": false,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
@ -21,7 +21,7 @@
|
|||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
"launchBrowser": true,
|
"launchBrowser": false,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
@ -30,12 +30,9 @@
|
|||||||
"Docker": {
|
"Docker": {
|
||||||
"commandName": "Docker",
|
"commandName": "Docker",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"publishAllPorts": true,
|
"publishAllPorts": true,
|
||||||
"useSSL": true
|
"useSSL": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,6 +10,7 @@ using FileSecurityService.Extensions;
|
|||||||
using ImageProvider.Extensions;
|
using ImageProvider.Extensions;
|
||||||
using JWTService.Extensions;
|
using JWTService.Extensions;
|
||||||
using HashService.Extensions;
|
using HashService.Extensions;
|
||||||
|
using Core.Middlewares;
|
||||||
|
|
||||||
namespace WeatherForecast {
|
namespace WeatherForecast {
|
||||||
|
|
||||||
@ -198,6 +199,9 @@ namespace WeatherForecast {
|
|||||||
// UseCors must be called before UseResponseCaching
|
// UseCors must be called before UseResponseCaching
|
||||||
app.UseCors(MyAllowSpecificOrigins);
|
app.UseCors(MyAllowSpecificOrigins);
|
||||||
|
|
||||||
|
// global error handler
|
||||||
|
app.UseMiddleware<ErrorHandlerMiddleware>();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
"Database": {
|
"Database": {
|
||||||
"ConnectionString": "mongodb://localhost:27017"
|
"ConnectionString": "mongodb://root:example@mongo:27017"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectVersion>2.1</ProjectVersion>
|
<ProjectVersion>2.1</ProjectVersion>
|
||||||
<DockerTargetOS>Linux</DockerTargetOS>
|
<DockerTargetOS>Linux</DockerTargetOS>
|
||||||
<ProjectGuid>38a28e4b-319a-44b0-aa9b-54f3f0362317</ProjectGuid>
|
<ProjectGuid>7fc6f0ba-2dcb-4b53-a3b3-61ceef42b9d0</ProjectGuid>
|
||||||
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
|
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
|
||||||
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
|
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
|
||||||
<DockerServiceName>weatherforecast</DockerServiceName>
|
<DockerServiceName>reverseproxy</DockerServiceName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="docker-compose.override.yml">
|
<None Include="docker-compose.override.yml">
|
||||||
|
|||||||
@ -1,12 +1,54 @@
|
|||||||
version: '3.4'
|
version: '3.4'
|
||||||
|
|
||||||
#services:
|
networks:
|
||||||
# weatherforecast:
|
my-network:
|
||||||
# environment:
|
driver: "bridge"
|
||||||
# - ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
# - ASPNETCORE_URLS=https://+:443;http://+:80
|
services:
|
||||||
# ports:
|
reverseproxy:
|
||||||
# - "80"
|
environment:
|
||||||
# - "443"
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
# volumes:
|
- ASPNETCORE_URLS=https://+:7174;http://+:5178
|
||||||
# - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
|
ports:
|
||||||
|
- "7174:7174"
|
||||||
|
- "5178:5178"
|
||||||
|
volumes:
|
||||||
|
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
|
||||||
|
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
|
||||||
|
networks:
|
||||||
|
- "my-network"
|
||||||
|
|
||||||
|
weatherforecast:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
- ASPNETCORE_URLS=https://+:7151;http://+:5133
|
||||||
|
volumes:
|
||||||
|
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
|
||||||
|
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
|
||||||
|
networks:
|
||||||
|
- "my-network"
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
image: mongo
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 27018:27017
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: example
|
||||||
|
volumes:
|
||||||
|
- ./docker-compose/mongo/data/db:/data/db
|
||||||
|
networks:
|
||||||
|
- "my-network"
|
||||||
|
|
||||||
|
mongo-express:
|
||||||
|
image: mongo-express
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
environment:
|
||||||
|
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
||||||
|
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
||||||
|
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
|
||||||
|
networks:
|
||||||
|
- "my-network"
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
version: '3.4'
|
version: '3.4'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
clientapp:
|
weatherforecast:
|
||||||
image: ${DOCKER_REGISTRY-}clientapp
|
image: ${DOCKER_REGISTRY-}weatherforecast
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ClientApp/Dockerfile
|
dockerfile: WeatherForecast/Dockerfile
|
||||||
|
reverseproxy:
|
||||||
|
image: ${DOCKER_REGISTRY-}reverseproxy
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ReverseProxy/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
#weatherforecast:
|
|
||||||
# image: ${DOCKER_REGISTRY-}weatherforecast
|
|
||||||
# build:
|
|
||||||
# context: .
|
|
||||||
# dockerfile: WeatherForecast/Dockerfile
|
|
||||||
|
|||||||
11
webapi/launchSettings.json
Normal file
11
webapi/launchSettings.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Docker Compose": {
|
||||||
|
"commandName": "DockerCompose",
|
||||||
|
"commandVersion": "1.0",
|
||||||
|
"serviceActions": {
|
||||||
|
"weatherforecast": "StartDebugging"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user