#39 search profiles
This commit is contained in:
parent
edd32cf9ed
commit
c54510d7d1
@ -415,6 +415,7 @@ namespace RMuseum.Controllers
|
||||
/// <summary>
|
||||
/// Get User Profiles
|
||||
/// </summary>
|
||||
/// <param name="artistName"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("profile")]
|
||||
[Authorize]
|
||||
@ -422,10 +423,10 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
|
||||
|
||||
public async Task<IActionResult> GetUserNarrationProfiles()
|
||||
public async Task<IActionResult> GetUserNarrationProfiles(string artistName)
|
||||
{
|
||||
Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
var res = await _audioService.GetUserNarrationProfiles(loggedOnUserId);
|
||||
var res = await _audioService.GetUserNarrationProfiles(loggedOnUserId, artistName);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
|
||||
|
||||
@ -791,10 +791,11 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.GetUserNarrationProfiles">
|
||||
<member name="M:RMuseum.Controllers.RecitationController.GetUserNarrationProfiles(System.String)">
|
||||
<summary>
|
||||
Get User Profiles
|
||||
</summary>
|
||||
<param name="artistName"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.GetUserDefProfile">
|
||||
@ -5094,11 +5095,12 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.RecitationService.GetUserNarrationProfiles(System.Guid)">
|
||||
<member name="M:RMuseum.Services.Implementation.RecitationService.GetUserNarrationProfiles(System.Guid,System.String)">
|
||||
<summary>
|
||||
Get User Profiles
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="artistName"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.RecitationService.GetUserDefProfile(System.Guid)">
|
||||
@ -5434,11 +5436,12 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.GetUserNarrationProfiles(System.Guid)">
|
||||
<member name="M:RMuseum.Services.IRecitationService.GetUserNarrationProfiles(System.Guid,System.String)">
|
||||
<summary>
|
||||
Get User Profiles
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="artistName"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.GetUserDefProfile(System.Guid)">
|
||||
|
||||
@ -111,8 +111,9 @@ namespace RMuseum.Services
|
||||
/// Get User Profiles
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="artistName"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<UserRecitationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId);
|
||||
Task<RServiceResult<UserRecitationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId, string artistName);
|
||||
|
||||
/// <summary>
|
||||
/// Get User Default Profile
|
||||
|
||||
@ -150,15 +150,19 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
try
|
||||
{
|
||||
bool rejected = recitation.ReviewStatus == AudioReviewStatus.Rejected;
|
||||
string mp3 = recitation.LocalMp3FilePath;
|
||||
string xml = recitation.LocalXmlFilePath;
|
||||
context.Recitations.Remove(recitation);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
if(File.Exists(mp3))
|
||||
File.Delete(mp3);
|
||||
if (File.Exists(xml))
|
||||
File.Delete(xml);
|
||||
if(!rejected)
|
||||
{
|
||||
if (File.Exists(mp3))
|
||||
File.Delete(mp3);
|
||||
if (File.Exists(xml))
|
||||
File.Delete(xml);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
@ -1195,19 +1199,29 @@ namespace RMuseum.Services.Implementation
|
||||
/// Get User Profiles
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="artistName"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<UserRecitationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId)
|
||||
public async Task<RServiceResult<UserRecitationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId, string artistName)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<UserRecitationProfileViewModel> profiles = new List<UserRecitationProfileViewModel>();
|
||||
|
||||
foreach (UserRecitationProfile p in (await _context.UserRecitationProfiles.Include(p => p.User).Where(p => p.UserId == userId && p.IsDefault == true).ToArrayAsync()))
|
||||
foreach (UserRecitationProfile p in
|
||||
(
|
||||
await _context.UserRecitationProfiles.Include(p => p.User)
|
||||
.Where(p => p.UserId == userId && p.IsDefault == true &&
|
||||
(string.IsNullOrEmpty(artistName) || (!string.IsNullOrEmpty(artistName) && p.ArtistName.Contains(artistName)))
|
||||
).ToArrayAsync())
|
||||
)
|
||||
{
|
||||
profiles.Add(new UserRecitationProfileViewModel(p));
|
||||
}
|
||||
|
||||
foreach (UserRecitationProfile p in (await _context.UserRecitationProfiles.Include(p => p.User).Where(p => p.UserId == userId && p.IsDefault == false).ToArrayAsync()))
|
||||
foreach (UserRecitationProfile p in (await _context.UserRecitationProfiles.Include(p => p.User).Where(p => p.UserId == userId && p.IsDefault == false
|
||||
&&
|
||||
(string.IsNullOrEmpty(artistName) || (!string.IsNullOrEmpty(artistName) && p.ArtistName.Contains(artistName)))
|
||||
).ToArrayAsync()))
|
||||
{
|
||||
profiles.Add(new UserRecitationProfileViewModel(p));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user