From cf67b70f9a1eac778944f547213c9f883e4a5888 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 4 Feb 2021 10:11:25 +0330 Subject: [PATCH] #72 removing UserRecitationProfileViewModel constructor --- .../PoemNarrationModerationResult.cs | 21 +++ .../ViewModels/RecitationModerateViewModel.cs | 19 --- .../UserRecitationProfileViewModel.cs | 41 +---- RMuseum/RMuseum.xml | 51 +++---- .../Implementation/RecitationService.cs | 141 +++++++++++++++++- 5 files changed, 179 insertions(+), 94 deletions(-) create mode 100644 RMuseum/Models/GanjoorAudio/ViewModels/PoemNarrationModerationResult.cs diff --git a/RMuseum/Models/GanjoorAudio/ViewModels/PoemNarrationModerationResult.cs b/RMuseum/Models/GanjoorAudio/ViewModels/PoemNarrationModerationResult.cs new file mode 100644 index 00000000..37f29ae4 --- /dev/null +++ b/RMuseum/Models/GanjoorAudio/ViewModels/PoemNarrationModerationResult.cs @@ -0,0 +1,21 @@ +namespace RMuseum.Models.GanjoorAudio.ViewModels +{ + /// + /// Moderation Result + /// + public enum PoemNarrationModerationResult + { + /// + /// no moderation + /// + MetadataNeedsFixation = 0, + /// + /// approve + /// + Approve = 1, + /// + /// reject + /// + Reject = 2 + } +} diff --git a/RMuseum/Models/GanjoorAudio/ViewModels/RecitationModerateViewModel.cs b/RMuseum/Models/GanjoorAudio/ViewModels/RecitationModerateViewModel.cs index d081d4a2..5ae539a7 100644 --- a/RMuseum/Models/GanjoorAudio/ViewModels/RecitationModerateViewModel.cs +++ b/RMuseum/Models/GanjoorAudio/ViewModels/RecitationModerateViewModel.cs @@ -1,24 +1,5 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels { - /// - /// Moderation Result - /// - public enum PoemNarrationModerationResult - { - /// - /// no moderation - /// - MetadataNeedsFixation = 0, - /// - /// approve - /// - Approve = 1, - /// - /// reject - /// - Reject = 2 - } - /// /// Poem Narration Moderation View Model /// diff --git a/RMuseum/Models/GanjoorAudio/ViewModels/UserRecitationProfileViewModel.cs b/RMuseum/Models/GanjoorAudio/ViewModels/UserRecitationProfileViewModel.cs index 2b3f82d2..1395c88c 100644 --- a/RMuseum/Models/GanjoorAudio/ViewModels/UserRecitationProfileViewModel.cs +++ b/RMuseum/Models/GanjoorAudio/ViewModels/UserRecitationProfileViewModel.cs @@ -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 /// public class UserRecitationProfileViewModel { - /// - /// parameterless constructor - /// - public UserRecitationProfileViewModel() - { - - } - /// - /// constructor - /// - /// - 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; - - } - /// + /// /// Id /// /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 2a33008d..2ac55892 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -2392,6 +2392,26 @@ is default + + + Moderation Result + + + + + no moderation + + + + + approve + + + + + reject + + Public (no user specific data) for publish recitations @@ -2487,26 +2507,6 @@ Poem Html Text - - - Moderation Result - - - - - no moderation - - - - - approve - - - - - reject - - Poem Narration Moderation View Model @@ -2814,17 +2814,6 @@ UserNarrationProfile View Model - - - parameterless constructor - - - - - constructor - - - Id diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index b07a1394..20ab7117 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -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(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(null); - return new RServiceResult(new UserRecitationProfileViewModel(defProfile)); + return new RServiceResult + ( + 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(new UserRecitationProfileViewModel(p)); + return new RServiceResult + ( + 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(new UserRecitationProfileViewModel(p)); + return new RServiceResult + ( + 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) {