Class PostController
- Namespace
- GastroSky.Controllers.V1
- Assembly
- GastroSky.dll
User post endpoints.
[ApiController]
[Authorize]
[Route("api/v1/posts")]
[Produces("application/json", new string[] { })]
public class PostController : GastroSkyControllerBase
- Inheritance
-
PostController
- Inherited Members
Constructors
PostController(GastroSkyDatabaseContext, ISlugGenerator, ITranslationRequestService, IMapper, ILogger<PostController>)
User post endpoints.
public PostController(GastroSkyDatabaseContext db, ISlugGenerator slugGenerator, ITranslationRequestService translationRequestService, IMapper mapper, ILogger<PostController> logger)
Parameters
dbGastroSkyDatabaseContextslugGeneratorISlugGeneratortranslationRequestServiceITranslationRequestServicemapperIMapperloggerILogger<PostController>
Methods
ArchivePost(PostArchivalRequestDto)
Archives a post draft. After successful archival, it will no longer be live for everybody to see and it will only be accessible in an authorized manner via the archive.
[HttpPut]
[Route("archive")]
[ProducesResponseType(400)]
[ProducesResponseType(403)]
[ProducesResponseType(404)]
[ProducesResponseType(500)]
[ProducesResponseType<ResponseBodyDto<PostResponseDto>>(200)]
public Task<IActionResult> ArchivePost(PostArchivalRequestDto dto)
Parameters
dtoPostArchivalRequestDtoRequest DTO containing the post archival details. Check out the API DocFX documentation on PostArchivalRequestDto for more information.
Returns
Remarks
Sample request:
PUT /api/v1/posts/archive
{
"slug": "postslug",
"archive": true
}
CreatePost(PostCreationRequestDto)
Creates a new post.
[HttpPost]
[Route("")]
[ProducesResponseType(400)]
[ProducesResponseType(403)]
[ProducesResponseType(500)]
[ProducesResponseType<ResponseBodyDto<PostResponseDto>>(201)]
public Task<IActionResult> CreatePost(PostCreationRequestDto dto)
Parameters
dtoPostCreationRequestDtoRequest DTO containing the post creation details. Check out the API DocFX documentation on PostCreationRequestDto for more information.
Returns
Remarks
Sample request:
POST /api/v1/posts
{
"authorUserSlug": "userslug",
"titleTranslationsJson": "JSON_PAYLOAD_HERE",
"subtitleTranslationsJson": "JSON_PAYLOAD_HERE",
"address": "Musterstrasse 123",
"zipCode": "4125",
"location": "Riehen",
"descriptionMarkdownTranslationsJson": "JSON_PAYLOAD_HERE",
"category": 1,
"itemTypes": [
0, 1, 2
],
"internalSurfaceSquareMeters": 123,
"externalSurfaceSquareMeters": null,
"internalSeatCount": 0,
"externalSeatCount": 0,
"lastRenovationYear": 2019,
"lastRenovationDescriptionTextTranslationsJson": "JSON_PAYLOAD_HERE",
"currency": "CHF",
"salePriceSubunit": 4200000,
"monthlyRentPriceSubunit": null,
"yearlyRentPriceSubunit": null,
"annualGrossRevenueSubunit": null,
"customSlug": "mybar",
"customEmail": "user@example.com",
"customPhone": "+41790000000",
"customWebsiteURL": "https://example.com",
"hideEmail": false,
"hidePhone": false,
"thumbnailPictureBytesBase64": null,
"countryCodeISO": "CHE"
}
DeletePost(string)
Deletes a post.
[HttpDelete]
[Route("{slug}")]
[ProducesResponseType(400)]
[ProducesResponseType(403)]
[ProducesResponseType(404)]
[ProducesResponseType(500)]
[ProducesResponseType<ResponseBodyDto<PostDeletionResponseDto>>(200)]
public Task<IActionResult> DeletePost(string slug)
Parameters
slugstringPost slug.
Returns
Remarks
After successful deletion, it will no longer be accessible. Not even in the archive. It will only continue to exist inside the DB for legal reasons for at least 20 years.
GetFavoritePosts()
[HttpGet]
[Route("favorites")]
[ProducesResponseType(403)]
[ProducesResponseType<ResponseBodyDto<PublicPostReducedResponseDto>>(200)]
public Task<IActionResult> GetFavoritePosts()
Returns
GetPostFilters(string?)
[HttpGet]
[Route("filters")]
[AllowAnonymous]
public Task<IActionResult> GetPostFilters(string? region)
Parameters
regionstring
Returns
GetPostImages(string)
Gets a specific post images.
[HttpGet]
[Route("private/{slug}/post-images")]
[ProducesResponseType<ResponseBodyDto<PostImageResponseDto>>(200)]
public Task<IActionResult> GetPostImages(string slug)
Parameters
slugstringPost slug.
Returns
GetPostPublicImages(string)
Gets a specific post images, if post is premium.
[HttpGet]
[Route("{slug}/post-images")]
[ProducesResponseType<ResponseBodyDto<PostImageResponseDto>>(200)]
public Task<IActionResult> GetPostPublicImages(string slug)
Parameters
slugstringPost slug.
Returns
GetPrivatePost(string)
Gets a specific private post.
[HttpGet]
[Route("private/{slug}")]
[ProducesResponseType(403)]
[ProducesResponseType(404)]
[ProducesResponseType<ResponseBodyDto<PostResponseDto>>(200)]
public Task<IActionResult> GetPrivatePost(string slug)
Parameters
slugstringPost slug string.
Returns
GetPrivatePosts(PostQueryParameters?)
Gets a list of private posts with optional filters applied.
[HttpGet]
[Route("private")]
[ProducesResponseType(400)]
[ProducesResponseType(403)]
[ProducesResponseType<ResponseBodyDto<PrivatePostReducedResponseDto>>(200)]
public Task<IActionResult> GetPrivatePosts(PostQueryParameters? postQueryParameters = null)
Parameters
postQueryParametersPostQueryParameters
Returns
Remarks
To reduce response size, only a redux DTO collection will be returned. The full posts can be retrieved individually via their slug from the GET endpoint. Check out the DocFX API docs PublicPostReducedResponseDto page for more details.
GetPublicPost(string)
Gets a specific post.
[HttpGet]
[Route("{slug}")]
[AllowAnonymous]
[ProducesResponseType(404)]
[ProducesResponseType<ResponseBodyDto<PostResponseDto>>(200)]
public Task<IActionResult> GetPublicPost(string slug)
Parameters
slugstringPost slug string.
Returns
GetPublicPosts(PostQueryParameters?)
Gets a list of posts with optional filters applied.
[HttpGet]
[Route("")]
[AllowAnonymous]
[ProducesResponseType(400)]
[ProducesResponseType<ResponseBodyDto<PublicPostReducedResponseDto>>(200)]
public Task<IActionResult> GetPublicPosts(PostQueryParameters? postQueryParameters = null)
Parameters
postQueryParametersPostQueryParameters
Returns
Remarks
To reduce response size, only a redux DTO collection will be returned. The full posts can be retrieved individually via their slug from the GET endpoint. Check out the DocFX API docs PublicPostReducedResponseDto page for more details.
IsPremiumPost(string)
Checks whether a specific post is premium-allocated.
[HttpGet]
[Route("check-premium/{slug}")]
[ProducesResponseType(404)]
[ProducesResponseType<ResponseBodyDto<PostPremiumCheckResponseDto>>(200)]
public Task<IActionResult> IsPremiumPost(string slug)
Parameters
slugstringThe post's slug.
Returns
Remarks
Check out the DocFX API docs about Post for more details.
ModifyPost(PostModificationRequestDto)
Modifies an existing post.
[HttpPut]
[Route("")]
[ProducesResponseType(400)]
[ProducesResponseType(402)]
[ProducesResponseType(403)]
[ProducesResponseType(404)]
[ProducesResponseType(500)]
[ProducesResponseType<ResponseBodyDto<PostResponseDto>>(200)]
public Task<IActionResult> ModifyPost(PostModificationRequestDto dto)
Parameters
dtoPostModificationRequestDtoRequest DTO containing the post modification details. Check out the API DocFX documentation on PostModificationRequestDto for more information.
Returns
Remarks
Sample request:
PUT /api/v1/posts
{
"slug": "postslug",
"titleTranslationsJson": "JSON_PAYLOAD_HERE",
"subtitleTranslationsJson": "JSON_PAYLOAD_HERE",
"address": "Musterstrasse 123",
"zipCode": "4125",
"location": "Riehen",
"descriptionMarkdownTranslationsJson": "JSON_PAYLOAD_HERE",
"category": 1,
"itemTypes": [
0, 1, 2
],
"internalSurfaceSquareMeters": 123,
"externalSurfaceSquareMeters": null,
"internalSeatCount": 0,
"externalSeatCount": 0,
"lastRenovationYear": 2019,
"lastRenovationDescriptionTextTranslationsJson": "JSON_PAYLOAD_HERE",
"currency": "CHF",
"salePriceSubunit": 4200000,
"monthlyRentPriceSubunit": null,
"yearlyRentPriceSubunit": null,
"annualGrossRevenueSubunit": null,
"customEmail": "user@example.com",
"customPhone": "+41790000000",
"customWebsiteURL": "https://example.com",
"hideEmail": false,
"hidePhone": false,
"thumbnailPictureBytesBase64": null,
"countryCodeISO": "CHE"
}
PublishPost(PostPublicationRequestDto)
Publishes a post draft. After successful publication, it will be live for everybody to see.
[HttpPut]
[Route("publish")]
[ProducesResponseType(400)]
[ProducesResponseType(403)]
[ProducesResponseType(404)]
[ProducesResponseType(500)]
[ProducesResponseType<ResponseBodyDto<PostResponseDto>>(200)]
public Task<IActionResult> PublishPost(PostPublicationRequestDto dto)
Parameters
dtoPostPublicationRequestDtoRequest DTO containing the post publication details. Check out the API DocFX documentation on PostPublicationRequestDto for more information.
Returns
Remarks
Sample request:
PUT /api/v1/posts/publish
{
"slug": "postslug",
"publish": true
}
UpdateMainPostImage(string, Guid)
Updates a post main image
[HttpPut]
[Route("{slug}/main-post-image/{guid:guid}")]
[ProducesResponseType<ResponseBodyDto<PostImageResponseDto>>(200)]
public Task<IActionResult> UpdateMainPostImage(string slug, Guid guid)