diff --git a/RMuseum/Controllers/GanjoorPoetSuggestedPhotosController.cs b/RMuseum/Controllers/GanjoorPoetSuggestedPhotosController.cs index f634b233..87dc4ba1 100644 --- a/RMuseum/Controllers/GanjoorPoetSuggestedPhotosController.cs +++ b/RMuseum/Controllers/GanjoorPoetSuggestedPhotosController.cs @@ -179,6 +179,25 @@ namespace RMuseum.Controllers return Ok(res.Result); } + /// + /// delete published suggested photo + /// + /// + /// + [HttpDelete("{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 DeletePoetSuggestedPhotoAsync(int id) + { + + var res = await _poetPhotosService.DeletePoetSuggestedPhotoAsync(id); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result); + } + /// /// Poets Photos Service /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 629492d5..8443c2ad 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -2042,6 +2042,13 @@ + + + delete published suggested photo + + + + Poets Photos Service @@ -16761,6 +16768,13 @@ + + + delete published suggested photo + + + + Database Context @@ -17448,6 +17462,13 @@ + + + delete published suggested photo + + + + Audio Narration Service diff --git a/RMuseum/Services/IPoetPhotoSuggestionService.cs b/RMuseum/Services/IPoetPhotoSuggestionService.cs index 89e7db8b..217e506d 100644 --- a/RMuseum/Services/IPoetPhotoSuggestionService.cs +++ b/RMuseum/Services/IPoetPhotoSuggestionService.cs @@ -66,6 +66,13 @@ namespace RMuseum.Services /// Task> RejectPoetSuggestedPhotosAsync(int id, Guid deleteUserId, string rejectionCause); + /// + /// delete published suggested photo + /// + /// + /// + Task> DeletePoetSuggestedPhotoAsync(int id); + } } diff --git a/RMuseum/Services/Implementation/PoetPhotoSuggestionService.cs b/RMuseum/Services/Implementation/PoetPhotoSuggestionService.cs index 2e05392b..106bd0f3 100644 --- a/RMuseum/Services/Implementation/PoetPhotoSuggestionService.cs +++ b/RMuseum/Services/Implementation/PoetPhotoSuggestionService.cs @@ -372,6 +372,30 @@ namespace RMuseum.Services.Implementation } } + /// + /// delete published suggested photo + /// + /// + /// + public async Task> DeletePoetSuggestedPhotoAsync(int id) + { + try + { + var dbModel = await _context.GanjoorPoetSuggestedPictures.Where(s => s.Id == id).SingleAsync(); + if(dbModel.Published) + { + return new RServiceResult(false, "برای رد تصاویر تأیید نشده از تابع reject استفاده کنید."); + } + _context.Remove(dbModel); + await _context.SaveChangesAsync(); + return new RServiceResult(true); + } + catch (Exception exp) + { + return new RServiceResult(false, exp.ToString()); + } + } + /// /// Database Context