diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index 72d6e4c8..b82e2e8d 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -744,6 +744,13 @@ namespace RMuseum.Services /// Task> GetPoetSuggestedSpecLinesAsync(int poetId, Guid? userId, bool includeUnpublished); + /// + /// returns specfic suggested line for poet + /// + /// + /// + Task> GetPoetSuggestedSpecLinesAsync(int id); + /// /// add a suggestion for poets spec lines /// diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PhotosProject.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PhotosProject.cs index 2acd1713..f318f94b 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PhotosProject.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PhotosProject.cs @@ -51,6 +51,43 @@ namespace RMuseum.Services.Implementation ); } + /// + /// returns specfic suggested line for poet + /// + /// + /// + public async Task> GetPoetSuggestedSpecLinesAsync(int id) + { + try + { + + return new RServiceResult + ( + await _context.GanjoorPoetSuggestedSpecLines + .Where + ( + r => r.Id == id + ) + .Select + ( + r => new GanjoorPoetSuggestedSpecLineViewModel() + { + Id = r.Id, + PoetId = r.PoetId, + LineOrder = r.LineOrder, + Contents = r.Contents, + Published = r.Published, + SuggestedById = r.SuggestedById + } + ).SingleAsync() + ); + } + catch (Exception exp) + { + return new RServiceResult(null, exp.ToString()); + } + } + /// /// add a suggestion for poets spec lines /// @@ -90,7 +127,7 @@ namespace RMuseum.Services.Implementation { try { - + var dbModel = await _context.GanjoorPoetSuggestedSpecLines.Where(s => s.Id == model.Id).SingleAsync(); bool publishIsChanged = model.Published != dbModel.Published; dbModel.LineOrder = model.LineOrder; @@ -99,7 +136,7 @@ namespace RMuseum.Services.Implementation _context.Update(dbModel); await _context.SaveChangesAsync(); - if(publishIsChanged && model.Published && dbModel.SuggestedById != null) + if (publishIsChanged && model.Published && dbModel.SuggestedById != null) { var userRes = await _appUserService.GetUserInformation((Guid)dbModel.SuggestedById); var poet = await _context.GanjoorPoets.AsNoTracking().Where(p => p.Id == dbModel.PoetId).SingleAsync();