Merge pull request #4084 from abpframework/maliming/patch-2

Update usage codes in modules and templates.
pull/4164/head
Halil İbrahim Kalkan 6 years ago committed by GitHub
commit 12c76626df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -216,9 +216,9 @@ However, it provides the following methods those can be used to query a single e
* `FindAsync(id)` returns the entity or null if not found.
* `GetAsync(id)` method returns the entity or throws an `EntityNotFoundException` (which causes HTTP 404 status code) if not found.
#### Sync vs Async
#### Sync vs Async
ABP Framework repository has no sync methods (like `Insert`). All the methods are async (like `InsertAsync`). So, if your application has sync repository method usages, convert them to async versions.
ABP Framework repository has no sync methods (like `Insert`). All the methods are async (like `InsertAsync`). So, if your application has sync repository method usages, convert them to async versions.
In general, ABP Framework forces you to completely use async everywhere, because mixing async & sync methods is not a recommended approach.
@ -444,7 +444,7 @@ ASP.NET Boilerplate uses Castle Windsor's [logging facility](http://docs.castlep
using Castle.Core.Logging; //1: Import Logging namespace
public class TaskAppService : ITaskAppService
{
{
//2: Getting a logger using property injection
public ILogger Logger { get; set; }
@ -693,26 +693,22 @@ public class AbpTenantManagementWebMainMenuContributor : IMenuContributor
var administrationMenu = context.Menu.GetAdministration();
//Resolve some needed services from the DI container
var authorizationService = context.ServiceProvider
.GetRequiredService<IAuthorizationService>();
var l = context.ServiceProvider
.GetRequiredService<IStringLocalizer<AbpTenantManagementResource>>();
var l = context.GetLocalizer<AbpTenantManagementResource>();
var tenantManagementMenuItem = new ApplicationMenuItem(
TenantManagementMenuNames.GroupName,
l["Menu:TenantManagement"],
icon: "fa fa-users");
administrationMenu.AddItem(tenantManagementMenuItem);
//Conditionally add the "Tenants" menu item based on the permission
if (await authorizationService
.IsGrantedAsync(TenantManagementPermissions.Tenants.Default))
if (await context.IsGrantedAsync(TenantManagementPermissions.Tenants.Default))
{
tenantManagementMenuItem.AddItem(
new ApplicationMenuItem(
TenantManagementMenuNames.Tenants,
l["Tenants"],
l["Tenants"],
url: "/TenantManagement/Tenants"));
}
}
@ -731,4 +727,4 @@ The following features are not present for the ABP Framework. Here, a list of so
* [Real time notification system](https://aspnetboilerplate.com/Pages/Documents/Notification-System) ([#633](https://github.com/abpframework/abp/issues/633))
* [NHibernate Integration](https://aspnetboilerplate.com/Pages/Documents/NHibernate-Integration) ([#339](https://github.com/abpframework/abp/issues/339)) - We don't intent to work on this, but any community contribution welcome.
Some of these features will eventually be implemented. However, you can implement them yourself if they are important for you. If you want, you can [contribute](Contribution/Index.md) to the framework, it is appreciated.
Some of these features will eventually be implemented. However, you can implement them yourself if they are important for you. If you want, you can [contribute](Contribution/Index.md) to the framework, it is appreciated.

@ -16,8 +16,8 @@ namespace Volo.Abp.Account.Web
return Task.CompletedTask;
}
var uiResource = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpUiResource>>();
var accountResource = context.ServiceProvider.GetRequiredService<IStringLocalizer<AccountResource>>();
var uiResource = context.GetLocalizer<AbpUiResource>();
var accountResource = context.GetLocalizer<AccountResource>();
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountResource["ManageYourProfile"], url: "/Account/Manage", icon: "fa fa-cog", order: 1000, null));
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", uiResource["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
@ -25,4 +25,4 @@ namespace Volo.Abp.Account.Web
return Task.CompletedTask;
}
}
}
}

@ -19,15 +19,14 @@ namespace Volo.Blogging
private async Task ConfigureMainMenu(MenuConfigurationContext context)
{
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<BloggingResource>>();
var l = context.GetLocalizer<BloggingResource>();
if (await authorizationService.IsGrantedAsync(BloggingPermissions.Blogs.Management))
if (await context.IsGrantedAsync(BloggingPermissions.Blogs.Management))
{
var managementRootMenuItem = new ApplicationMenuItem("BlogManagement", l["Menu:BlogManagement"]);
//TODO: Using the same permission. Reconsider.
if (await authorizationService.IsGrantedAsync(BloggingPermissions.Blogs.Management))
if (await context.IsGrantedAsync(BloggingPermissions.Blogs.Management))
{
managementRootMenuItem.AddItem(new ApplicationMenuItem("BlogManagement.Blogs", l["Menu:Blogs"], "/Admin/Blogs"));
}

@ -19,17 +19,15 @@ namespace Volo.Docs.Admin.Navigation
private async Task ConfigureMainMenu(MenuConfigurationContext context)
{
var administrationMenu = context.Menu.GetAdministration();
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<DocsResource>>();
var l = context.GetLocalizer<DocsResource>();
var rootMenuItem = new ApplicationMenuItem(DocsMenuNames.GroupName, l["Menu:DocumentManagement"], icon: "fa fa-book");
administrationMenu.AddItem(rootMenuItem);
if (await authorizationService.IsGrantedAsync(DocsAdminPermissions.Projects.Default))
if (await context.IsGrantedAsync(DocsAdminPermissions.Projects.Default))
{
rootMenuItem.AddItem(new ApplicationMenuItem(DocsMenuNames.Projects, l["Menu:ProjectManagement"], "/Docs/Admin/Projects"));
}

@ -16,17 +16,14 @@ namespace Volo.Abp.Identity.Web.Navigation
return;
}
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
var hasRolePermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Roles.Default);
var hasUserPermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Users.Default);
var hasRolePermission = await context.IsGrantedAsync(IdentityPermissions.Roles.Default);
var hasUserPermission = await context.IsGrantedAsync(IdentityPermissions.Users.Default);
if (hasRolePermission || hasUserPermission)
{
var administrationMenu = context.Menu.GetAdministration();
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<IdentityResource>>();
var l = context.GetLocalizer<IdentityResource>();
var identityMenuItem = new ApplicationMenuItem(IdentityMenuNames.GroupName, l["Menu:IdentityManagement"], icon: "fa fa-id-card-o");
administrationMenu.AddItem(identityMenuItem);
@ -43,4 +40,4 @@ namespace Volo.Abp.Identity.Web.Navigation
}
}
}
}
}

@ -29,7 +29,7 @@ namespace Volo.Abp.SettingManagement.Web.Navigation
return;
}
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpSettingManagementResource>>();
var l = context.GetLocalizer<AbpSettingManagementResource>();
context.Menu
.GetAdministration()

@ -18,13 +18,12 @@ namespace Volo.Abp.TenantManagement.Web.Navigation
var administrationMenu = context.Menu.GetAdministration();
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpTenantManagementResource>>();
var l = context.GetLocalizer<AbpTenantManagementResource>();
var tenantManagementMenuItem = new ApplicationMenuItem(TenantManagementMenuNames.GroupName, l["Menu:TenantManagement"], icon: "fa fa-users");
administrationMenu.AddItem(tenantManagementMenuItem);
if (await authorizationService.IsGrantedAsync(TenantManagementPermissions.Tenants.Default))
if (await context.IsGrantedAsync(TenantManagementPermissions.Tenants.Default))
{
tenantManagementMenuItem.AddItem(new ApplicationMenuItem(TenantManagementMenuNames.Tenants, l["Tenants"], url: "/TenantManagement/Tenants"));
}

@ -15,7 +15,7 @@ namespace Volo.Abp.VirtualFileExplorer.Web.Navigation
return Task.CompletedTask;
}
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<VirtualFileExplorerResource>>();
var l = context.GetLocalizer<VirtualFileExplorerResource>();
context.Menu.Items.Add(new ApplicationMenuItem(VirtualFileExplorerMenuNames.Index, l["Menu:VirtualFileExplorer"], icon: "fa fa-file", url: "/VirtualFileExplorer"));

@ -19,13 +19,11 @@ namespace ProductManagement
private async Task ConfigureMainMenu(MenuConfigurationContext context)
{
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<ProductManagementResource>>();
var l = context.GetLocalizer<ProductManagementResource>();
var rootMenuItem = new ApplicationMenuItem("ProductManagement", l["Menu:ProductManagement"]);
if (await authorizationService.IsGrantedAsync(ProductManagementPermissions.Products.Default))
if (await context.IsGrantedAsync(ProductManagementPermissions.Products.Default))
{
rootMenuItem.AddItem(new ApplicationMenuItem("Products", l["Menu:Products"], "/ProductManagement/Products"));
}
@ -33,4 +31,4 @@ namespace ProductManagement
context.Menu.AddItem(rootMenuItem);
}
}
}
}

@ -41,7 +41,7 @@ namespace MyCompanyName.MyProjectName.Web.Menus
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Insert(0, new ApplicationMenuItem("MyProjectName.Home", l["Menu:Home"], "/"));
@ -50,8 +50,8 @@ namespace MyCompanyName.MyProjectName.Web.Menus
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
var accountStringLocalizer = context.ServiceProvider.GetRequiredService<IStringLocalizer<AccountResource>>();
var l = context.GetLocalizer<MyProjectNameResource>();
var accountStringLocalizer = context.GetLocalizer<AccountResource>();
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";

@ -26,7 +26,7 @@ namespace MyCompanyName.MyProjectName.Web.Menus
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Insert(0, new ApplicationMenuItem("MyProjectName.Home", l["Menu:Home"], "/"));
}

@ -32,17 +32,17 @@ namespace MyCompanyName.MyProjectName
private void AddLogoutItemToMenu(MenuConfigurationContext context)
{
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
var l = context.GetLocalizer<MyProjectNameResource>();
if (currentUser.IsAuthenticated)
{
context.Menu.Items.Add(new ApplicationMenuItem(
"Account.Manage",
l["ManageYourProfile"],
"Account.Manage",
l["ManageYourProfile"],
$"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage",
icon: "fa fa-cog",
order: int.MaxValue - 1001,
null,
null,
"_blank")
);
@ -57,4 +57,4 @@ namespace MyCompanyName.MyProjectName
}
}
}
}
}

Loading…
Cancel
Save