diff --git a/RMuseum/Controllers/AudioNarrationController.cs b/RMuseum/Controllers/AudioNarrationController.cs
index 405c3a2a..71e9a64a 100644
--- a/RMuseum/Controllers/AudioNarrationController.cs
+++ b/RMuseum/Controllers/AudioNarrationController.cs
@@ -126,7 +126,11 @@ namespace RMuseum.Controllers
return BadRequest(res.ExceptionString);
}
- [HttpGet("profiles")]
+ ///
+ /// Get User Profiles
+ ///
+ ///
+ [HttpGet("profile")]
[Authorize]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
@@ -145,6 +149,32 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
+ ///
+ /// Add a narration profile
+ ///
+ ///
+ ///
+ [HttpPost("profile")]
+ [Authorize]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UserNarrationProfileViewModel))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
+
+ public async Task AddUserNarrationProfiles([FromBody]UserNarrationProfileViewModel profile)
+ {
+ Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
+
+ profile.UserId = loggedOnUserId;
+
+
+ var res = await _audioService.AddUserNarrationProfiles(profile);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+
+
+ return Ok(res.Result);
+ }
+
///
/// constructor
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index ec1c9cd6..5d90ad2e 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -641,6 +641,19 @@
+
+
+ Get User Profiles
+
+
+
+
+
+ Add a narration profile
+
+
+
+
constructor
@@ -3546,6 +3559,13 @@
+
+
+ Add a narration profile
+
+
+
+
IArtifactService implementation
@@ -4310,6 +4330,13 @@
+
+
+ Add a narration profile
+
+
+
+
Configuration
diff --git a/RMuseum/Services/IAudioNarrationService.cs b/RMuseum/Services/IAudioNarrationService.cs
index cc224cef..52d585b6 100644
--- a/RMuseum/Services/IAudioNarrationService.cs
+++ b/RMuseum/Services/IAudioNarrationService.cs
@@ -65,6 +65,13 @@ namespace RMuseum.Services
///
Task> GetUserNarrationProfiles(Guid userId);
+ ///
+ /// Add a narration profile
+ ///
+ ///
+ ///
+ Task> AddUserNarrationProfiles(UserNarrationProfileViewModel profile);
+
}
}
diff --git a/RMuseum/Services/Implementation/AudioNarrationService.cs b/RMuseum/Services/Implementation/AudioNarrationService.cs
index 6761fb68..0e78695c 100644
--- a/RMuseum/Services/Implementation/AudioNarrationService.cs
+++ b/RMuseum/Services/Implementation/AudioNarrationService.cs
@@ -456,6 +456,45 @@ namespace RMuseum.Services.Implementation
}
}
+ ///
+ /// Add a narration profile
+ ///
+ ///
+ ///
+ public async Task> AddUserNarrationProfiles(UserNarrationProfileViewModel profile)
+ {
+ try
+ {
+ var p = new UserNarrationProfile()
+ {
+ UserId = profile.UserId,
+ ArtistName = profile.ArtistName,
+ ArtistUrl = profile.ArtistUrl,
+ AudioSrc = profile.AudioSrc,
+ AudioSrcUrl = profile.AudioSrcUrl,
+ FileSuffixWithoutDash = profile.FileSuffixWithoutDash,
+ IsDefault = profile.IsDefault
+ };
+ await _context.UserNarrationProfiles.AddAsync(p);
+
+ await _context.SaveChangesAsync();
+ if(p.IsDefault)
+ {
+ foreach(var o in _context.UserNarrationProfiles.Where(o => o.Id != p.Id && o.IsDefault).Select(o => o))
+ {
+ o.IsDefault = false;
+ _context.UserNarrationProfiles.Update(o);
+ }
+ await _context.UserNarrationProfiles.AddAsync(p);
+ }
+ return new RServiceResult(new UserNarrationProfileViewModel(p));
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
///
/// Configuration
///