docs: #275 adding rejection cause to reject photo/spec rejection api and changing them from DELETE to PUT

This commit is contained in:
Hamid Reza Mohammadi 2022-02-24 09:22:43 +03:30
parent 0d0b9b420a
commit c07d46e12d
6 changed files with 23 additions and 15 deletions

View File

@ -160,19 +160,20 @@ namespace RMuseum.Controllers
}
/// <summary>
/// delete a suggestion for poets photos
/// reject a suggestion for poets photos
/// </summary>
/// <param name="id"></param>
/// <param name="rejectionCause"></param>
/// <returns></returns>
[HttpDelete("{id}")]
[HttpPut("reject/{id}")]
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ModeratePoetPhotos)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
public async Task<IActionResult> DeletePoetSuggestedPhotosAsync(int id)
public async Task<IActionResult> RejectPoetSuggestedPhotosAsync(int id, [FromBody] string rejectionCause)
{
Guid userId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
var res = await _poetPhotosService.DeletePoetSuggestedPhotoAsync(id, userId);
var res = await _poetPhotosService.RejectPoetSuggestedPhotosAsync(id, userId, rejectionCause);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);

View File

@ -130,19 +130,20 @@ namespace RMuseum.Controllers
}
/// <summary>
/// delete a suggestion for poets spec lines
/// reject a suggestion for poets spec lines
/// </summary>
/// <param name="id"></param>
/// <param name="rejectionCause"></param>
/// <returns></returns>
[HttpDelete("{id}")]
[HttpPut("reject/{id}")]
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ModeratePoetPhotos)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
public async Task<IActionResult> DeletePoetSuggestedSpecLinesAsync(int id)
public async Task<IActionResult> RejectPoetSuggestedSpecLinesAsync(int id, [FromBody] string rejectionCause)
{
Guid userId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
var res = await _ganjoorService.DeletePoetSuggestedSpecLinesAsync(id, userId);
var res = await _ganjoorService.RejectPoetSuggestedSpecLinesAsync(id, userId, rejectionCause);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);

View File

@ -808,11 +808,12 @@ namespace RMuseum.Services
Task<RServiceResult<bool>> ModifyPoetSuggestedSpecLinesAsync(GanjoorPoetSuggestedSpecLineViewModel model);
/// <summary>
/// delete a suggestion for poets spec lines
/// reject a suggestion for poets spec lines
/// </summary>
/// <param name="id"></param>
/// <param name="deleteUserId"></param>
/// <param name="rejectionCause"></param>
/// <returns></returns>
Task<RServiceResult<bool>> DeletePoetSuggestedSpecLinesAsync(int id, Guid deleteUserId);
Task<RServiceResult<bool>> RejectPoetSuggestedSpecLinesAsync(int id, Guid deleteUserId, string rejectionCause);
}
}

View File

@ -62,8 +62,9 @@ namespace RMuseum.Services
/// </summary>
/// <param name="id"></param>
/// <param name="deleteUserId"></param>
/// <param name="rejectionCause"></param>
/// <returns></returns>
Task<RServiceResult<bool>> DeletePoetSuggestedPhotoAsync(int id, Guid deleteUserId);
Task<RServiceResult<bool>> RejectPoetSuggestedPhotosAsync(int id, Guid deleteUserId, string rejectionCause);
}

View File

@ -237,8 +237,9 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="id"></param>
/// <param name="deleteUserId"></param>
/// <param name="rejectionCause"></param>
/// <returns></returns>
public async Task<RServiceResult<bool>> DeletePoetSuggestedSpecLinesAsync(int id, Guid deleteUserId)
public async Task<RServiceResult<bool>> RejectPoetSuggestedSpecLinesAsync(int id, Guid deleteUserId, string rejectionCause)
{
try
{
@ -249,9 +250,10 @@ namespace RMuseum.Services.Implementation
{
var userRes = await _appUserService.GetUserInformation((Guid)dbModel.SuggestedById);
var poet = await _context.GanjoorPoets.AsNoTracking().Where(p => p.Id == dbModel.PoetId).SingleAsync();
string causePhrase = string.IsNullOrEmpty(rejectionCause) ? "" : $" به دلیل {rejectionCause} ";
await _notificationService.PushNotification((Guid)dbModel.SuggestedById,
$"عدم پذیرش مشارکت شما در مشخصات {poet.Nickname}",
$"متأسفانه پیشنهاد شما برای مشخصات {poet.Nickname} مورد پذیرش قرار نگرفت. پیشنها شما: {Environment.NewLine}" +
$"متأسفانه پیشنهاد شما برای مشخصات {poet.Nickname}{causePhrase} مورد پذیرش قرار نگرفت. پیشنها شما: {Environment.NewLine}" +
$"{dbModel.Contents}"
);
}

View File

@ -311,8 +311,9 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="id"></param>
/// <param name="deleteUserId"></param>
/// <param name="rejectionCause"></param>
/// <returns></returns>
public async Task<RServiceResult<bool>> DeletePoetSuggestedPhotoAsync(int id, Guid deleteUserId)
public async Task<RServiceResult<bool>> RejectPoetSuggestedPhotosAsync(int id, Guid deleteUserId, string rejectionCause)
{
try
{
@ -323,9 +324,10 @@ namespace RMuseum.Services.Implementation
{
var userRes = await _appUserService.GetUserInformation((Guid)dbModel.SuggestedById);
var poet = await _context.GanjoorPoets.AsNoTracking().Where(p => p.Id == dbModel.PoetId).SingleAsync();
string causePhrase = string.IsNullOrEmpty(rejectionCause) ? "" : $" به دلیل {rejectionCause} ";
await _notificationService.PushNotification((Guid)dbModel.SuggestedById,
$"عدم پذیرش تصویر ارسالی شما برای {poet.Nickname}",
$"متأسفانه تصویر پیشنهادی شما برای مشخصات {poet.Nickname} مورد پذیرش قرار نگرفت"
$"متأسفانه تصویر پیشنهادی شما برای مشخصات {poet.Nickname}{causePhrase} مورد پذیرش قرار نگرفت"
);
}