#72 removing UserRecitationProfileViewModel constructor

This commit is contained in:
Hamid Reza Mohammadi 2021-02-04 10:11:25 +03:30
parent f39854e652
commit cf67b70f9a
5 changed files with 179 additions and 94 deletions

View File

@ -0,0 +1,21 @@
namespace RMuseum.Models.GanjoorAudio.ViewModels
{
/// <summary>
/// Moderation Result
/// </summary>
public enum PoemNarrationModerationResult
{
/// <summary>
/// no moderation
/// </summary>
MetadataNeedsFixation = 0,
/// <summary>
/// approve
/// </summary>
Approve = 1,
/// <summary>
/// reject
/// </summary>
Reject = 2
}
}

View File

@ -1,24 +1,5 @@
namespace RMuseum.Models.GanjoorAudio.ViewModels
{
/// <summary>
/// Moderation Result
/// </summary>
public enum PoemNarrationModerationResult
{
/// <summary>
/// no moderation
/// </summary>
MetadataNeedsFixation = 0,
/// <summary>
/// approve
/// </summary>
Approve = 1,
/// <summary>
/// reject
/// </summary>
Reject = 2
}
/// <summary>
/// Poem Narration Moderation View Model
/// </summary>

View File

@ -1,5 +1,4 @@
using RSecurityBackend.Models.Auth.Db;
using RSecurityBackend.Models.Auth.ViewModels;
using RSecurityBackend.Models.Auth.ViewModels;
using System;
namespace RMuseum.Models.GanjoorAudio.ViewModels
@ -9,43 +8,7 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// </summary>
public class UserRecitationProfileViewModel
{
/// <summary>
/// parameterless constructor
/// </summary>
public UserRecitationProfileViewModel()
{
}
/// <summary>
/// constructor
/// </summary>
/// <param name="src"></param>
public UserRecitationProfileViewModel(UserRecitationProfile src)
{
RAppUser appUser = src.User;
Id = src.Id;
User = src.User == null ? null : new PublicRAppUser()
{
Id = appUser.Id,
Username = appUser.UserName,
Email = appUser.Email,
FirstName = appUser.FirstName,
SureName = appUser.SureName,
PhoneNumber = appUser.PhoneNumber,
RImageId = appUser.RImageId,
Status = appUser.Status
};
UserId = src.UserId;
Name = src.Name;
FileSuffixWithoutDash = src.FileSuffixWithoutDash;
ArtistName = src.ArtistName;
ArtistUrl = src.ArtistUrl;
AudioSrc = src.AudioSrc;
AudioSrcUrl = src.AudioSrcUrl;
IsDefault = src.IsDefault;
}
/// <summary>
/// <summary>
/// Id
/// </summary>
/// <remarks>

View File

@ -2392,6 +2392,26 @@
is default
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult">
<summary>
Moderation Result
</summary>
</member>
<member name="F:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult.MetadataNeedsFixation">
<summary>
no moderation
</summary>
</member>
<member name="F:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult.Approve">
<summary>
approve
</summary>
</member>
<member name="F:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult.Reject">
<summary>
reject
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorAudio.ViewModels.PublicRecitationViewModel">
<summary>
Public (no user specific data) for publish recitations
@ -2487,26 +2507,6 @@
Poem Html Text
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult">
<summary>
Moderation Result
</summary>
</member>
<member name="F:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult.MetadataNeedsFixation">
<summary>
no moderation
</summary>
</member>
<member name="F:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult.Approve">
<summary>
approve
</summary>
</member>
<member name="F:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationModerationResult.Reject">
<summary>
reject
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorAudio.ViewModels.RecitationModerateViewModel">
<summary>
Poem Narration Moderation View Model
@ -2814,17 +2814,6 @@
UserNarrationProfile View Model
</summary>
</member>
<member name="M:RMuseum.Models.GanjoorAudio.ViewModels.UserRecitationProfileViewModel.#ctor">
<summary>
parameterless constructor
</summary>
</member>
<member name="M:RMuseum.Models.GanjoorAudio.ViewModels.UserRecitationProfileViewModel.#ctor(RMuseum.Models.GanjoorAudio.UserRecitationProfile)">
<summary>
constructor
</summary>
<param name="src"></param>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.ViewModels.UserRecitationProfileViewModel.Id">
<summary>
Id

View File

@ -14,6 +14,7 @@ using RMuseum.Models.UploadSession;
using RMuseum.Models.UploadSession.ViewModels;
using RMuseum.Services.Implementation;
using RMuseum.Services.Implementation.ImportedFromDesktopGanjoor;
using RSecurityBackend.Models.Auth.ViewModels;
using RSecurityBackend.Models.Generic;
using RSecurityBackend.Services;
using RSecurityBackend.Services.Implementation;
@ -1614,7 +1615,33 @@ namespace RMuseum.Services.Implementationa
).ToArrayAsync())
)
{
profiles.Add(new UserRecitationProfileViewModel(p));
profiles.Add
(
new UserRecitationProfileViewModel()
{
Id = p.Id,
User = p.User == null ? null :
new PublicRAppUser()
{
Id = p.User.Id,
Username = p.User.UserName,
Email = p.User.Email,
FirstName = p.User.FirstName,
SureName = p.User.SureName,
PhoneNumber = p.User.PhoneNumber,
RImageId = p.User.RImageId,
Status = p.User.Status
},
UserId = p.UserId,
Name = p.Name,
FileSuffixWithoutDash = p.FileSuffixWithoutDash,
ArtistName = p.ArtistName,
ArtistUrl = p.ArtistUrl,
AudioSrc = p.AudioSrc,
AudioSrcUrl = p.AudioSrcUrl,
IsDefault = p.IsDefault
}
);
}
foreach (UserRecitationProfile p in (await _context.UserRecitationProfiles.Include(p => p.User).Where(p => p.UserId == userId && p.IsDefault == false
@ -1622,7 +1649,33 @@ namespace RMuseum.Services.Implementationa
(string.IsNullOrEmpty(artistName) || (!string.IsNullOrEmpty(artistName) && p.ArtistName.Contains(artistName)))
).ToArrayAsync()))
{
profiles.Add(new UserRecitationProfileViewModel(p));
profiles.Add
(
new UserRecitationProfileViewModel()
{
Id = p.Id,
User = p.User == null ? null :
new PublicRAppUser()
{
Id = p.User.Id,
Username = p.User.UserName,
Email = p.User.Email,
FirstName = p.User.FirstName,
SureName = p.User.SureName,
PhoneNumber = p.User.PhoneNumber,
RImageId = p.User.RImageId,
Status = p.User.Status
},
UserId = p.UserId,
Name = p.Name,
FileSuffixWithoutDash = p.FileSuffixWithoutDash,
ArtistName = p.ArtistName,
ArtistUrl = p.ArtistUrl,
AudioSrc = p.AudioSrc,
AudioSrcUrl = p.AudioSrcUrl,
IsDefault = p.IsDefault
}
);
}
return new RServiceResult<UserRecitationProfileViewModel[]>(profiles.ToArray());
@ -1645,7 +1698,33 @@ namespace RMuseum.Services.Implementationa
var defProfile = await _context.UserRecitationProfiles.Include(p => p.User).Where(p => p.UserId == userId && p.IsDefault == true).FirstOrDefaultAsync();
if (defProfile == null)
return new RServiceResult<UserRecitationProfileViewModel>(null);
return new RServiceResult<UserRecitationProfileViewModel>(new UserRecitationProfileViewModel(defProfile));
return new RServiceResult<UserRecitationProfileViewModel>
(
new UserRecitationProfileViewModel()
{
Id = defProfile.Id,
User = defProfile.User == null ? null :
new PublicRAppUser()
{
Id = defProfile.User.Id,
Username = defProfile.User.UserName,
Email = defProfile.User.Email,
FirstName = defProfile.User.FirstName,
SureName = defProfile.User.SureName,
PhoneNumber = defProfile.User.PhoneNumber,
RImageId = defProfile.User.RImageId,
Status = defProfile.User.Status
},
UserId = defProfile.UserId,
Name = defProfile.Name,
FileSuffixWithoutDash = defProfile.FileSuffixWithoutDash,
ArtistName = defProfile.ArtistName,
ArtistUrl = defProfile.ArtistUrl,
AudioSrc = defProfile.AudioSrc,
AudioSrcUrl = defProfile.AudioSrcUrl,
IsDefault = defProfile.IsDefault
}
);
}
catch (Exception exp)
{
@ -1767,7 +1846,33 @@ namespace RMuseum.Services.Implementationa
}
await _context.SaveChangesAsync();
}
return new RServiceResult<UserRecitationProfileViewModel>(new UserRecitationProfileViewModel(p));
return new RServiceResult<UserRecitationProfileViewModel>
(
new UserRecitationProfileViewModel()
{
Id = p.Id,
User = p.User == null ? null :
new PublicRAppUser()
{
Id = p.User.Id,
Username = p.User.UserName,
Email = p.User.Email,
FirstName = p.User.FirstName,
SureName = p.User.SureName,
PhoneNumber = p.User.PhoneNumber,
RImageId = p.User.RImageId,
Status = p.User.Status
},
UserId = p.UserId,
Name = p.Name,
FileSuffixWithoutDash = p.FileSuffixWithoutDash,
ArtistName = p.ArtistName,
ArtistUrl = p.ArtistUrl,
AudioSrc = p.AudioSrc,
AudioSrcUrl = p.AudioSrcUrl,
IsDefault = p.IsDefault
}
);
}
catch (Exception exp)
{
@ -1821,7 +1926,33 @@ namespace RMuseum.Services.Implementationa
}
await _context.SaveChangesAsync();
}
return new RServiceResult<UserRecitationProfileViewModel>(new UserRecitationProfileViewModel(p));
return new RServiceResult<UserRecitationProfileViewModel>
(
new UserRecitationProfileViewModel()
{
Id = p.Id,
User = p.User == null ? null :
new PublicRAppUser()
{
Id = p.User.Id,
Username = p.User.UserName,
Email = p.User.Email,
FirstName = p.User.FirstName,
SureName = p.User.SureName,
PhoneNumber = p.User.PhoneNumber,
RImageId = p.User.RImageId,
Status = p.User.Status
},
UserId = p.UserId,
Name = p.Name,
FileSuffixWithoutDash = p.FileSuffixWithoutDash,
ArtistName = p.ArtistName,
ArtistUrl = p.ArtistUrl,
AudioSrc = p.AudioSrc,
AudioSrcUrl = p.AudioSrcUrl,
IsDefault = p.IsDefault
}
);
}
catch (Exception exp)
{