Refactoring (#314)
* Refactoring * Refactoring * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Rename template .sql file * Modified null and empty string check. * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Added Favicon support, Progressive Web App support, page title and url support, and private/public user registration options * Refactoring * Refactoring * Check for a valid email. * Moved logic to the Utilities class. Co-authored-by: Aubrey <aubrey.b@treskcow.tech> Co-authored-by: MIchael Atwood <matwood@dragonmastery.com> Co-authored-by: Shaun Walker <shaun.walker@siliqon.com>
This commit is contained in:
		| @ -46,13 +46,14 @@ | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } } | ||||
|     public override string Title { get { return "Send Notification"; } } | ||||
|     private List<UserRole> userroles; | ||||
|     private string userid = "-1"; | ||||
|     private string subject = ""; | ||||
|     private string body = ""; | ||||
|  | ||||
|     List<UserRole> userroles; | ||||
|     string userid = "-1"; | ||||
|     string subject = ""; | ||||
|     string body = ""; | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; | ||||
|  | ||||
|     public override string Title => "Send Notification"; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
| @ -71,7 +72,7 @@ | ||||
|  | ||||
|     private async Task Send() | ||||
|     { | ||||
|         Notification notification = new Notification(); | ||||
|         var notification = new Notification(); | ||||
|         try | ||||
|         { | ||||
|             notification.SiteId = PageState.Site.SiteId; | ||||
|  | ||||
| @ -172,20 +172,20 @@ | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } } | ||||
|     private string username = string.Empty; | ||||
|     private string password = string.Empty; | ||||
|     private string confirm = string.Empty; | ||||
|     private string email = string.Empty; | ||||
|     private string displayname = string.Empty; | ||||
|     private FileManager filemanager; | ||||
|     private int photofileid = -1; | ||||
|     private List<Profile> profiles; | ||||
|     private Dictionary<string, string> settings; | ||||
|     private string category = string.Empty; | ||||
|     private string filter = "to"; | ||||
|     private List<Notification> notifications; | ||||
|  | ||||
|     string username = ""; | ||||
|     string password = ""; | ||||
|     string confirm = ""; | ||||
|     string email = ""; | ||||
|     string displayname = ""; | ||||
|     FileManager filemanager; | ||||
|     int photofileid = -1; | ||||
|     List<Profile> profiles; | ||||
|     Dictionary<string, string> settings; | ||||
|     string category = ""; | ||||
|     string filter = "to"; | ||||
|     List<Notification> notifications; | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
| @ -196,12 +196,15 @@ | ||||
|                 username = PageState.User.Username; | ||||
|                 email = PageState.User.Email; | ||||
|                 displayname = PageState.User.DisplayName; | ||||
|                  | ||||
|                 if (PageState.User.PhotoFileId != null) | ||||
|                 { | ||||
|                     photofileid = PageState.User.PhotoFileId.Value; | ||||
|                 } | ||||
|                  | ||||
|                 profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId); | ||||
|                 settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId); | ||||
|                  | ||||
|                 await LoadNotificationsAsync(); | ||||
|             } | ||||
|             else | ||||
| @ -223,29 +226,29 @@ | ||||
|     } | ||||
|  | ||||
|     private string GetProfileValue(string SettingName, string DefaultValue) | ||||
|     { | ||||
|         return SettingService.GetSetting(settings, SettingName, DefaultValue); | ||||
|     } | ||||
|         => SettingService.GetSetting(settings, SettingName, DefaultValue); | ||||
|  | ||||
|     private async Task Save() | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             if (username != "" && email != "") | ||||
|             if (username != string.Empty && email != string.Empty) | ||||
|             { | ||||
|                 if (password == confirm) | ||||
|                 { | ||||
|                     User user = PageState.User; | ||||
|                     var user = PageState.User; | ||||
|                     user.Username = username; | ||||
|                     user.Password = password; | ||||
|                     user.Email = email; | ||||
|                     user.DisplayName = (displayname == "" ? username : displayname); | ||||
|                     user.DisplayName = (displayname == string.Empty ? username : displayname); | ||||
|                     user.PhotoFileId = null; | ||||
|                     photofileid = filemanager.GetFileId(); | ||||
|                      | ||||
|                     if (photofileid != -1) | ||||
|                     { | ||||
|                         user.PhotoFileId = photofileid; | ||||
|                     } | ||||
|                      | ||||
|                     await UserService.UpdateUserAsync(user); | ||||
|                     await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId); | ||||
|                     await logger.LogInformation("User Profile Saved"); | ||||
| @ -269,12 +272,12 @@ | ||||
|  | ||||
|     private void Cancel() | ||||
|     { | ||||
|         NavigationManager.NavigateTo(NavigateUrl("")); | ||||
|         NavigationManager.NavigateTo(NavigateUrl(string.Empty)); | ||||
|     } | ||||
|  | ||||
|     private void ProfileChanged(ChangeEventArgs e, string SettingName) | ||||
|     { | ||||
|         string value = (string)e.Value; | ||||
|         var value = (string)e.Value; | ||||
|         settings = SettingService.SetSetting(settings, SettingName, value); | ||||
|     } | ||||
|  | ||||
| @ -291,6 +294,7 @@ | ||||
|             { | ||||
|                 await NotificationService.DeleteNotificationAsync(Notification.NotificationId); | ||||
|             } | ||||
|              | ||||
|             await logger.LogInformation("Notification Deleted {Notification}", Notification); | ||||
|             await LoadNotificationsAsync(); | ||||
|             StateHasChanged(); | ||||
| @ -305,6 +309,7 @@ | ||||
|     private async void FilterChanged(ChangeEventArgs e) | ||||
|     { | ||||
|         filter = (string)e.Value; | ||||
|          | ||||
|         await LoadNotificationsAsync(); | ||||
|         StateHasChanged(); | ||||
|     } | ||||
|  | ||||
| @ -52,7 +52,7 @@ | ||||
|             </td> | ||||
|         </tr> | ||||
|     </table> | ||||
|     @if (reply != "") | ||||
|     @if (reply != string.Empty) | ||||
|     { | ||||
|         <button type="button" class="btn btn-primary" @onclick="Send">Send</button> | ||||
|     } | ||||
| @ -70,17 +70,17 @@ | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.View; } } | ||||
|     public override string Title { get { return "View Notification"; } } | ||||
|     private int notificationid; | ||||
|     private string title = string.Empty; | ||||
|     private List<UserRole> userroles; | ||||
|     private string userid = "-1"; | ||||
|     private string subject = string.Empty; | ||||
|     private string createdon = string.Empty; | ||||
|     private string body = string.Empty; | ||||
|     private string reply = string.Empty; | ||||
|  | ||||
|     int notificationid; | ||||
|     string title = ""; | ||||
|     List<UserRole> userroles; | ||||
|     string userid = "-1"; | ||||
|     string subject = ""; | ||||
|     string createdon = ""; | ||||
|     string body = ""; | ||||
|     string reply = ""; | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; | ||||
|     public override string Title => "View Notification"; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
| @ -110,6 +110,7 @@ | ||||
|                         userid = notification.ToUserId.ToString(); | ||||
|                     } | ||||
|                 } | ||||
|                  | ||||
|                 subject = notification.Subject; | ||||
|                 createdon = notification.CreatedOn.ToString(); | ||||
|                 body = notification.Body; | ||||
| @ -132,11 +133,11 @@ | ||||
|  | ||||
|     private async Task Send() | ||||
|     { | ||||
|         Notification notification = new Notification(); | ||||
|         var notification = new Notification(); | ||||
|         notification.SiteId = PageState.Site.SiteId; | ||||
|         notification.FromUserId = PageState.User.UserId; | ||||
|         notification.ToUserId = int.Parse(userid); | ||||
|         notification.ToEmail = ""; | ||||
|         notification.ToEmail = string.Empty; | ||||
|         notification.Subject = subject; | ||||
|         notification.Body = body; | ||||
|         notification.ParentId = notificationid; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Hisham Bin Ateya
					Hisham Bin Ateya