fix Localizer class specification
This commit is contained in:
		| @ -6,7 +6,7 @@ | ||||
| @inject IPageService PageService | ||||
| @inject IPageModuleService PageModuleService | ||||
| @inject IUserService UserService | ||||
| @inject IStringLocalizer<Index> Localizer | ||||
| @inject IStringLocalizer<Detail> Localizer | ||||
|  | ||||
| <table class="table table-borderless"> | ||||
|     <tr> | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
| @inject IModuleDefinitionService ModuleDefinitionService | ||||
| @inject IModuleService ModuleService | ||||
| @inject ISettingService SettingService | ||||
| @inject IStringLocalizer<Index> Localizer | ||||
| @inject IStringLocalizer<Create> Localizer | ||||
|  | ||||
| @if (_templates != null) | ||||
| { | ||||
|  | ||||
| @ -6,7 +6,7 @@ | ||||
| @inject IModuleService ModuleService | ||||
| @inject IPageModuleService PageModuleService | ||||
| @inject ISettingService SettingService | ||||
| @inject IStringLocalizer<Index> Localizer | ||||
| @inject IStringLocalizer<Create> Localizer | ||||
|  | ||||
| @if (_templates != null) | ||||
| { | ||||
|  | ||||
| @ -1,73 +1,73 @@ | ||||
| @namespace Oqtane.Modules.Admin.UserProfile | ||||
| @inherits ModuleBase | ||||
| @inject NavigationManager NavigationManager | ||||
| @inject IUserService UserService | ||||
| @namespace Oqtane.Modules.Admin.UserProfile | ||||
| @inherits ModuleBase | ||||
| @inject NavigationManager NavigationManager | ||||
| @inject IUserService UserService | ||||
| @inject INotificationService NotificationService | ||||
| @inject IStringLocalizer<Add> Localizer | ||||
|  | ||||
| @if (PageState.User != null) | ||||
| { | ||||
|     <table class="table table-borderless"> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <input id="to" class="form-control" @bind="@username" /> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <input id="subject" class="form-control" @bind="@subject" /> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="message" HelpText="Enter the message" ResourceKey="Message">Message: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <textarea id="message" class="form-control" @bind="@body" rows="5" /> | ||||
|             </td> | ||||
|         </tr> | ||||
|     </table> | ||||
|     <button type="button" class="btn btn-primary" @onclick="Send">@Localizer["Send"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private string username = ""; | ||||
|     private string subject = ""; | ||||
|     private string body = ""; | ||||
|  | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; | ||||
|  | ||||
|     public override string Title => "Send Notification"; | ||||
|  | ||||
|     private async Task Send() | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); | ||||
|             if (user != null) | ||||
| @inject IStringLocalizer<Add> Localizer | ||||
|  | ||||
| @if (PageState.User != null) | ||||
| { | ||||
|     <table class="table table-borderless"> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="to" HelpText="Enter the username you wish to send a message to" ResourceKey="To">To: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <input id="to" class="form-control" @bind="@username" /> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="subject" HelpText="Enter the subject of the message" ResourceKey="Subject">Subject: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <input id="subject" class="form-control" @bind="@subject" /> | ||||
|             </td> | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <Label For="message" HelpText="Enter the message" ResourceKey="Message">Message: </Label> | ||||
|             </td> | ||||
|             <td> | ||||
|                 <textarea id="message" class="form-control" @bind="@body" rows="5" /> | ||||
|             </td> | ||||
|         </tr> | ||||
|     </table> | ||||
|     <button type="button" class="btn btn-primary" @onclick="Send">@Localizer["Send"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private string username = ""; | ||||
|     private string subject = ""; | ||||
|     private string body = ""; | ||||
|  | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; | ||||
|  | ||||
|     public override string Title => "Send Notification"; | ||||
|  | ||||
|     private async Task Send() | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); | ||||
|             if (user != null) | ||||
|             { | ||||
|                 var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, null); | ||||
|                 notification = await NotificationService.AddNotificationAsync(notification); | ||||
|                 await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|                 notification = await NotificationService.AddNotificationAsync(notification); | ||||
|                 await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -1,201 +1,201 @@ | ||||
| @namespace Oqtane.Modules.Admin.UserProfile | ||||
| @inherits ModuleBase | ||||
| @inject NavigationManager NavigationManager | ||||
| @inject IUserService UserService | ||||
| @namespace Oqtane.Modules.Admin.UserProfile | ||||
| @inherits ModuleBase | ||||
| @inject NavigationManager NavigationManager | ||||
| @inject IUserService UserService | ||||
| @inject INotificationService NotificationService | ||||
| @inject IStringLocalizer<View> Localizer | ||||
|  | ||||
| @if (PageState.User != null) | ||||
| { | ||||
|     <table class="table table-borderless"> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <label class="control-label">@Localizer["Title"] </label> | ||||
|             </td> | ||||
|             @if (title == "From") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@username" readonly /> | ||||
|                 </td> | ||||
|             } | ||||
|             @if (title == "To") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@username" /> | ||||
|                 </td> | ||||
|             } | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <label class="control-label">@Localizer["Subject"] </label> | ||||
|             </td> | ||||
|             @if (title == "From") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@subject" readonly /> | ||||
|                 </td> | ||||
|             } | ||||
|             @if (title == "To") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@subject" /> | ||||
|                 </td> | ||||
|             } | ||||
|         </tr> | ||||
|         @if (title == "From") | ||||
|         { | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label class="control-label">@Localizer["Date"] </label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@createdon" readonly /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         } | ||||
|         @if (title == "From") | ||||
|         { | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label class="control-label">@Localizer["Message"] </label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <textarea class="form-control" @bind="@body" rows="5" readonly /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         } | ||||
|         @if (title == "To") | ||||
|         { | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label class="control-label">@Localizer["Message"] </label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <textarea class="form-control" @bind="@body" rows="5" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         } | ||||
|     </table> | ||||
|  | ||||
|  | ||||
|     @if (reply != string.Empty) | ||||
|     { | ||||
| @inject IStringLocalizer<View> Localizer | ||||
|  | ||||
| @if (PageState.User != null) | ||||
| { | ||||
|     <table class="table table-borderless"> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <label class="control-label">@Localizer["Title"] </label> | ||||
|             </td> | ||||
|             @if (title == "From") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@username" readonly /> | ||||
|                 </td> | ||||
|             } | ||||
|             @if (title == "To") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@username" /> | ||||
|                 </td> | ||||
|             } | ||||
|         </tr> | ||||
|         <tr> | ||||
|             <td> | ||||
|                 <label class="control-label">@Localizer["Subject"] </label> | ||||
|             </td> | ||||
|             @if (title == "From") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@subject" readonly /> | ||||
|                 </td> | ||||
|             } | ||||
|             @if (title == "To") | ||||
|             { | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@subject" /> | ||||
|                 </td> | ||||
|             } | ||||
|         </tr> | ||||
|         @if (title == "From") | ||||
|         { | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label class="control-label">@Localizer["Date"] </label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <input class="form-control" @bind="@createdon" readonly /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         } | ||||
|         @if (title == "From") | ||||
|         { | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label class="control-label">@Localizer["Message"] </label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <textarea class="form-control" @bind="@body" rows="5" readonly /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         } | ||||
|         @if (title == "To") | ||||
|         { | ||||
|             <tr> | ||||
|                 <td> | ||||
|                     <label class="control-label">@Localizer["Message"] </label> | ||||
|                 </td> | ||||
|                 <td> | ||||
|                     <textarea class="form-control" @bind="@body" rows="5" /> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         } | ||||
|     </table> | ||||
|  | ||||
|  | ||||
|     @if (reply != string.Empty) | ||||
|     { | ||||
|         <button type="button" class="btn btn-primary" @onclick="Send">@Localizer["Send"]</button> | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         if (title == "From") | ||||
|         { | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         if (title == "From") | ||||
|         { | ||||
|             <button type="button" class="btn btn-primary" @onclick="Reply">@Localizer["Reply"]</button> | ||||
|         } | ||||
|     } | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
|     <br /> | ||||
|     <br /> | ||||
|     @if (title == "To") | ||||
|     { | ||||
|         <div class="control-group"> | ||||
|             <label class="control-label">@Localizer["OriginalMessage"] </label> | ||||
|             <textarea class="form-control" @bind="@reply" rows="5" readonly /> | ||||
|         </div> | ||||
|     } | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private int notificationid; | ||||
|     private string title = string.Empty; | ||||
|     private string username = ""; | ||||
|     private string subject = string.Empty; | ||||
|     private string createdon = string.Empty; | ||||
|     private string body = string.Empty; | ||||
|     private string reply = string.Empty; | ||||
|  | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; | ||||
|     public override string Title => "View Notification"; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             notificationid = Int32.Parse(PageState.QueryString["id"]); | ||||
|             Notification notification = await NotificationService.GetNotificationAsync(notificationid); | ||||
|             if (notification != null) | ||||
|             { | ||||
|                 int userid = -1; | ||||
|                 if (notification.ToUserId == PageState.User.UserId) | ||||
|                 { | ||||
|                     title = "From"; | ||||
|                     if (notification.FromUserId != null) | ||||
|                     { | ||||
|                         userid = notification.FromUserId.Value; | ||||
|                     } | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     title = "To"; | ||||
|                     if (notification.ToUserId != null) | ||||
|                     { | ||||
|                         userid = notification.ToUserId.Value; | ||||
|                     } | ||||
|                 } | ||||
|                 if (userid != -1) | ||||
|                 { | ||||
|                     var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId); | ||||
|                     if (user != null) | ||||
|                     { | ||||
|                         username = user.Username; | ||||
|                     } | ||||
|                 } | ||||
|                 if (username == "") | ||||
|                 { | ||||
|                     username = "System"; | ||||
|                 } | ||||
|                 subject = notification.Subject; | ||||
|                 createdon = notification.CreatedOn.ToString(); | ||||
|                 body = notification.Body; | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Loading Users {Error}", ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void Reply() | ||||
|     { | ||||
|         title = "To"; | ||||
|         if (!subject.Contains("RE:")) | ||||
|         { | ||||
|             subject = "RE: " + subject; | ||||
|         } | ||||
|         reply = body; | ||||
|         body = "\n\n____________________________________________\nSent: " + createdon + "\nSubject: " + subject + "\n\n" + body; | ||||
|         StateHasChanged(); | ||||
|     } | ||||
|  | ||||
|     private async Task Send() | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); | ||||
|             if (user != null) | ||||
|         } | ||||
|     } | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink> | ||||
|     <br /> | ||||
|     <br /> | ||||
|     @if (title == "To") | ||||
|     { | ||||
|         <div class="control-group"> | ||||
|             <label class="control-label">@Localizer["OriginalMessage"] </label> | ||||
|             <textarea class="form-control" @bind="@reply" rows="5" readonly /> | ||||
|         </div> | ||||
|     } | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private int notificationid; | ||||
|     private string title = string.Empty; | ||||
|     private string username = ""; | ||||
|     private string subject = string.Empty; | ||||
|     private string createdon = string.Empty; | ||||
|     private string body = string.Empty; | ||||
|     private string reply = string.Empty; | ||||
|  | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; | ||||
|     public override string Title => "View Notification"; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             notificationid = Int32.Parse(PageState.QueryString["id"]); | ||||
|             Notification notification = await NotificationService.GetNotificationAsync(notificationid); | ||||
|             if (notification != null) | ||||
|             { | ||||
|                 int userid = -1; | ||||
|                 if (notification.ToUserId == PageState.User.UserId) | ||||
|                 { | ||||
|                     title = "From"; | ||||
|                     if (notification.FromUserId != null) | ||||
|                     { | ||||
|                         userid = notification.FromUserId.Value; | ||||
|                     } | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     title = "To"; | ||||
|                     if (notification.ToUserId != null) | ||||
|                     { | ||||
|                         userid = notification.ToUserId.Value; | ||||
|                     } | ||||
|                 } | ||||
|                 if (userid != -1) | ||||
|                 { | ||||
|                     var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId); | ||||
|                     if (user != null) | ||||
|                     { | ||||
|                         username = user.Username; | ||||
|                     } | ||||
|                 } | ||||
|                 if (username == "") | ||||
|                 { | ||||
|                     username = "System"; | ||||
|                 } | ||||
|                 subject = notification.Subject; | ||||
|                 createdon = notification.CreatedOn.ToString(); | ||||
|                 body = notification.Body; | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Loading Users {Error}", ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.User.Load"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void Reply() | ||||
|     { | ||||
|         title = "To"; | ||||
|         if (!subject.Contains("RE:")) | ||||
|         { | ||||
|             subject = "RE: " + subject; | ||||
|         } | ||||
|         reply = body; | ||||
|         body = "\n\n____________________________________________\nSent: " + createdon + "\nSubject: " + subject + "\n\n" + body; | ||||
|         StateHasChanged(); | ||||
|     } | ||||
|  | ||||
|     private async Task Send() | ||||
|     { | ||||
|         try | ||||
|         { | ||||
|             var user = await UserService.GetUserAsync(username, PageState.Site.SiteId); | ||||
|             if (user != null) | ||||
|             { | ||||
|                 var notification = new Notification(PageState.Site.SiteId, PageState.User, user, subject, body, notificationid); | ||||
|                 notification = await NotificationService.AddNotificationAsync(notification); | ||||
|                 await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
|                 notification = await NotificationService.AddNotificationAsync(notification); | ||||
|                 await logger.LogInformation("Notification Created {NotificationId}", notification.NotificationId); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["Message.User.Invalid"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Adding Notification {Error}", ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.Notification.Add"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker