docs: #283 adding API

This commit is contained in:
Hamid Reza Mohammadi 2022-02-18 08:24:11 +03:30
parent 7a505ba6ee
commit d391be3369
3 changed files with 92 additions and 2 deletions

View File

@ -1254,6 +1254,29 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
/// <summary>
/// get song by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("song/{id}")]
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ReviewSongs)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PoemMusicTrackViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden)]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> GetPoemSongById(int id)
{
var res =
await _ganjoorService.GetPoemSongById(id);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);
}
/// <summary>
/// history of suggested songs by a user
/// </summary>
@ -1295,6 +1318,52 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
/// <summary>
/// modify a published song
/// </summary>
/// <param name="song"></param>
/// <returns></returns>
[HttpPut]
[Route("song/update")]
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ReviewSongs)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PoemMusicTrackViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden)]
public async Task<IActionResult> ModifyPublishedSong([FromBody] PoemMusicTrackViewModel song)
{
if (ReadOnlyMode)
return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید.");
var res =
await _ganjoorService.ModifyPublishedSong(song);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);
}
/// <summary>
/// delete a poem song by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete]
[Route("song")]
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ReviewSongs)]
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden)]
public async Task<IActionResult> DeletePoemSongById(int id)
{
if (ReadOnlyMode)
return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید.");
var res =
await _ganjoorService.DeletePoemSongById(id);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok();
}
/// <summary>
/// directly insert a poem related song
/// </summary>

View File

@ -1109,6 +1109,13 @@
<param name="onlyMine"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemSongById(System.Int32)">
<summary>
get song by id
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetUserSongsSuggestionsStatistics(System.Guid)">
<summary>
history of suggested songs by a user
@ -1121,6 +1128,20 @@
<param name="song"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.ModifyPublishedSong(RMuseum.Models.Ganjoor.ViewModels.PoemMusicTrackViewModel)">
<summary>
modify a published song
</summary>
<param name="song"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.DeletePoemSongById(System.Int32)">
<summary>
delete a poem song by id
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.DirectInsertSong(RMuseum.Models.Ganjoor.ViewModels.PoemMusicTrackViewModel)">
<summary>
directly insert a poem related song
@ -12242,7 +12263,7 @@
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.DeletePoemSongById(System.Int32)">
<summary>
delete poem song by id
delete a poem song by id
</summary>
<param name="id"></param>
<returns></returns>

View File

@ -464,7 +464,7 @@ namespace RMuseum.Services.Implementation
}
/// <summary>
/// delete poem song by id
/// delete a poem song by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>