diff --git a/RMuseum/Controllers/RecitationController.cs b/RMuseum/Controllers/RecitationController.cs index f384f4bb..7a039ccc 100644 --- a/RMuseum/Controllers/RecitationController.cs +++ b/RMuseum/Controllers/RecitationController.cs @@ -432,6 +432,26 @@ namespace RMuseum.Controllers return Ok(res.Result); } + /// + /// Get User Default Profile + /// + /// + [HttpGet("profile/def")] + [Authorize] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UserRecitationProfileViewModel))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + [ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))] + + public async Task GetUserDefProfile() + { + Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); + var res = await _audioService.GetUserDefProfile(loggedOnUserId); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + + return Ok(res.Result); + } + /// /// Add a narration profile /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 64c6928b..3eef2a41 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -796,6 +796,12 @@ + + + Get User Default Profile + + + Add a narration profile @@ -5074,6 +5080,13 @@ + + + Get User Default Profile + + + + validating narration profile @@ -5397,6 +5410,13 @@ + + + Get User Default Profile + + + + Add a narration profile diff --git a/RMuseum/Services/IRecitationService.cs b/RMuseum/Services/IRecitationService.cs index c0caf388..2c2f76f5 100644 --- a/RMuseum/Services/IRecitationService.cs +++ b/RMuseum/Services/IRecitationService.cs @@ -113,6 +113,13 @@ namespace RMuseum.Services /// Task> GetUserNarrationProfiles(Guid userId); + /// + /// Get User Default Profile + /// + /// + /// + Task> GetUserDefProfile(Guid userId); + /// /// Add a narration profile /// diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index 7cc06e99..a3f7ee90 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -1139,6 +1139,23 @@ namespace RMuseum.Services.Implementation } } + /// + /// Get User Default Profile + /// + /// + /// + public async Task> GetUserDefProfile(Guid userId) + { + try + { + return new RServiceResult(new UserRecitationProfileViewModel(await _context.UserRecitationProfiles.Include(p => p.User).Where(p => p.UserId == userId && p.IsDefault == true).FirstOrDefaultAsync())); + } + catch (Exception exp) + { + return new RServiceResult(null, exp.ToString()); + } + } + /// /// validating narration profile ///