-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
MadWorld/MadWorld.Backend.API.Authorized/Functions/Blog/DeleteBlog.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Net; | ||
using LanguageExt; | ||
using LanguageExt.Common; | ||
using MadWorld.Backend.API.Shared.Authorization; | ||
using MadWorld.Backend.API.Shared.OpenAPI; | ||
using MadWorld.Shared.Contracts.Anonymous.Blog; | ||
using MadWorld.Shared.Contracts.Authorized.Account; | ||
using MadWorld.Shared.Contracts.Authorized.Blog; | ||
using MadWorld.Shared.Contracts.Shared.Authorization; | ||
using MadWorld.Shared.Contracts.Shared.Functions; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Http; | ||
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes; | ||
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums; | ||
using Microsoft.OpenApi.Models; | ||
|
||
namespace MadWorld.Backend.API.Authorized.Functions.Blog; | ||
|
||
public class DeleteBlog | ||
{ | ||
public DeleteBlog() | ||
{ | ||
} | ||
|
||
|
||
[Authorize(RoleTypes.Admin)] | ||
[Function("DeleteBlog")] | ||
[OpenApiSecurity(Security.SchemeName, SecuritySchemeType.ApiKey, Name = Security.HeaderName, In = OpenApiSecurityLocationType.Header)] | ||
[OpenApiOperation(operationId: "DeleteBlog", tags: new[] { "Blog" })] | ||
[OpenApiParameter("id", Required = true)] | ||
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(OkResponse), Description = "The OK response")] | ||
public Result<OkResponse> Run([HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "Blog/{id}")] HttpRequestData request, | ||
FunctionContext executionContext, | ||
string id) | ||
{ | ||
var deleteBlogRequest = new DeleteBlogRequest() | ||
{ | ||
Id = id | ||
}; | ||
|
||
return new OkResponse() | ||
{ | ||
Message = $"Blog {deleteBlogRequest.Id} has been deleted" | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
MadWorld/MadWorld.Shared.Contracts/Authorized/Blog/DeleteBlogRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MadWorld.Shared.Contracts.Authorized.Blog; | ||
|
||
public class DeleteBlogRequest | ||
{ | ||
public string Id { get; set; } = string.Empty; | ||
} |
7 changes: 7 additions & 0 deletions
7
MadWorld/MadWorld.Shared.Contracts/Shared/Functions/OkResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace MadWorld.Shared.Contracts.Shared.Functions; | ||
|
||
public class OkResponse : IResponse | ||
{ | ||
public bool IsSuccess { get; } = true; | ||
public string Message { get; set; } = string.Empty; | ||
} |