diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index d60cf038..40c8bef9 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -335,6 +335,26 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
+ ///
+ /// review song
+ ///
+ ///
+ ///
+ [HttpPut]
+ [Route("song")]
+ [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 ReviewSong([FromBody]PoemMusicTrackViewModel song)
+ {
+ var res =
+ await _ganjoorService.ReviewSong(song);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+ return Ok(res.Result);
+ }
+
///
/// get a random poem from hafez
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 17bbed6d..dcddb3f5 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -731,6 +731,13 @@
+
+
+ review song
+
+
+
+
get a random poem from hafez
@@ -5699,6 +5706,13 @@
+
+
+ review song
+
+
+
+
get a random poem from hafez
@@ -6540,6 +6554,13 @@
+
+
+ review song
+
+
+
+
get a random poem from hafez
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index 90ffbd4e..5c0b7f4c 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -131,6 +131,13 @@ namespace RMuseum.Services
///
Task> SuggestSong(Guid userId, PoemMusicTrackViewModel song);
+ ///
+ /// review song
+ ///
+ ///
+ ///
+ Task> ReviewSong(PoemMusicTrackViewModel song);
+
///
/// get a random poem from hafez
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index 17d4e676..6fc3e314 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -892,6 +892,54 @@ namespace RMuseum.Services.Implementation
}
}
+ ///
+ /// review song
+ ///
+ ///
+ ///
+ public async Task> ReviewSong(PoemMusicTrackViewModel song)
+ {
+ try
+ {
+ if (song.Approved && song.Rejected)
+ return new RServiceResult(null, "song.Approved && song.Rejected");
+
+ var track = await _context.GanjoorPoemMusicTracks.Where(t => t.Id == song.Id).SingleOrDefaultAsync();
+
+ track.TrackType = song.TrackType;
+ track.ArtistName = song.ArtistName;
+ track.ArtistUrl = song.ArtistUrl;
+ track.AlbumName = song.AlbumName;
+ track.AlbumUrl = song.AlbumUrl;
+ track.TrackName = song.TrackName;
+ track.TrackUrl = song.TrackUrl;
+ if(!track.Approved && song.Approved)
+ {
+ track.ApprovalDate = DateTime.Now;
+ }
+ track.Approved = song.Approved;
+ track.Rejected = song.Rejected;
+ track.RejectionCause = song.RejectionCause;
+ track.BrokenLink = song.BrokenLink;
+
+ GanjoorSinger singer = await _context.GanjoorSingers.Where(s => s.Url == track.ArtistUrl).FirstOrDefaultAsync();
+ if (singer != null)
+ {
+ track.SingerId = singer.Id;
+ }
+
+ _context.GanjoorPoemMusicTracks.Update(track);
+
+ await _context.SaveChangesAsync();
+
+ return new RServiceResult(song);
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
///
/// get a random poem from hafez
///