@@ -388,13 +388,15 @@ to get a deep understanding on creating menus.
388
388
dynamically defined based on the current user's permissions (see
389
389
authorization section). Example:
390
390
391
- if (abp.auth.hasPermission('Pages.Administration.Tenant.Settings')) {
392
- $stateProvider.state('tenant.settings', {
393
- url: '/settings',
394
- templateUrl: '~/App/tenant/views/settings/index.cshtml',
395
- menu: 'Administration.Settings.Tenant'
396
- });
397
- }
391
+ ``` javascript
392
+ if (abp .auth .hasPermission (' Pages.Administration.Tenant.Settings' )) {
393
+ $stateProvider .state (' tenant.settings' , {
394
+ url: ' /settings' ,
395
+ templateUrl: ' ~/App/tenant/views/settings/index.cshtml' ,
396
+ menu: ' Administration.Settings.Tenant'
397
+ });
398
+ }
399
+ ```
398
400
399
401
Conditional routing definition prevents users from accessing an
400
402
unauthorized page by simply entering a URL into the browser's address
@@ -850,13 +852,15 @@ You can also define your custom notifications in the
850
852
** AppNotificationProvider** class. For example, a new user registration
851
853
notification is defined in the ** AppNotificationProvider** as below.
852
854
853
- context.Manager.Add(
854
- new NotificationDefinition(
855
- AppNotificationNames.NewUserRegistered,
856
- displayName: L("NewUserRegisteredNotificationDefinition"),
857
- permissionDependency: new SimplePermissionDependency(AppPermissions.Pages_Administration_Users)
858
- )
859
- );
855
+ ``` csharp
856
+ context .Manager .Add (
857
+ new NotificationDefinition (
858
+ AppNotificationNames .NewUserRegistered ,
859
+ displayName : L (" NewUserRegisteredNotificationDefinition" ),
860
+ permissionDependency : new SimplePermissionDependency (AppPermissions .Pages_Administration_Users )
861
+ )
862
+ );
863
+ ```
860
864
861
865
See [ notification
862
866
definitions] ( https://aspnetboilerplate.com/Pages/Documents/Notification-System#notification-definitions )
@@ -1182,7 +1186,9 @@ as a cache server. If you want to enable it, just uncomment the
1182
1186
following line in your ** WebModule** (in App\_ Start folder in your .Web
1183
1187
project):
1184
1188
1185
- Configuration.Caching.UseRedis();
1189
+ ``` csharp
1190
+ Configuration .Caching .UseRedis ();
1191
+ ```
1186
1192
1187
1193
Redis server should be running to be able to use it. See [ caching
1188
1194
documentation] ( https://aspnetboilerplate.com/Pages/Documents/Caching )
@@ -1198,16 +1204,20 @@ easily enable it.
1198
1204
First, uncomment these lines in ** WebModule** (in App\_ Start folder in
1199
1205
your .Web project):
1200
1206
1201
- Configuration.BackgroundJobs.UseHangfire(configuration =>
1202
- {
1203
- configuration.GlobalConfiguration.UseSqlServerStorage("Default");
1204
- });
1207
+ ``` csharp
1208
+ Configuration .BackgroundJobs .UseHangfire (configuration =>
1209
+ {
1210
+ configuration .GlobalConfiguration .UseSqlServerStorage (" Default" );
1211
+ });
1212
+ ```
1205
1213
1206
1214
If you want to enable the Hangfire dashboard, you can uncomment the
1207
1215
following line in ** Startup.cs** (in App\_ Start folder in your .Web
1208
1216
project):
1209
1217
1210
- app.UseHangfireDashboard();
1218
+ ``` csharp
1219
+ app .UseHangfireDashboard ();
1220
+ ```
1211
1221
1212
1222
** Note** : Hangfire creates its ** own tables** in the database. See
1213
1223
[ background
@@ -1246,30 +1256,34 @@ that uses AutoMapper, which is simple and declarative.
1246
1256
See the DTO class that is used to transfer a tenant's editing
1247
1257
information:
1248
1258
1249
- [AutoMap(typeof (Tenant))]
1250
- public class TenantEditDto : EntityDto
1251
- {
1252
- [Required]
1253
- [StringLength(Tenant.MaxTenancyNameLength)]
1254
- public string TenancyName { get; set; }
1255
-
1256
- [Required]
1257
- [StringLength(Tenant.MaxNameLength)]
1258
- public string Name { get; set; }
1259
-
1260
- public bool IsActive { get; set; }
1261
- }
1259
+ ``` csharp
1260
+ [AutoMap (typeof (Tenant ))]
1261
+ public class TenantEditDto : EntityDto
1262
+ {
1263
+ [Required ]
1264
+ [StringLength (Tenant .MaxTenancyNameLength )]
1265
+ public string TenancyName { get ; set ; }
1266
+
1267
+ [Required ]
1268
+ [StringLength (Tenant .MaxNameLength )]
1269
+ public string Name { get ; set ; }
1270
+
1271
+ public bool IsActive { get ; set ; }
1272
+ }
1273
+ ```
1262
1274
1263
1275
Here, the ** AutoMap** attribute automatically creates mapping between
1264
1276
** TenantEditDto** and the ** Tenant** classes. Then you can automatically
1265
1277
convert a Tenant object to a TenantEditDto (and vice verse) object as
1266
1278
shown below:
1267
1279
1268
- [AbpAuthorize(AppPermissions.Pages_Tenants_Edit)]
1269
- public async Task<TenantEditDto> GetTenantForEdit(EntityRequestInput input)
1270
- {
1271
- return (await TenantManager.GetByIdAsync(input.Id)).MapTo<TenantEditDto>();
1272
- }
1280
+ ``` csharp
1281
+ [AbpAuthorize (AppPermissions .Pages_Tenants_Edit )]
1282
+ public async Task < TenantEditDto > GetTenantForEdit (EntityRequestInput input )
1283
+ {
1284
+ return (await TenantManager .GetByIdAsync (input .Id )).MapTo <TenantEditDto >();
1285
+ }
1286
+ ```
1273
1287
1274
1288
** MapTo** method does mapping.
1275
1289
@@ -1478,25 +1492,27 @@ It also provides some useful common methods for all tests.
1478
1492
1479
1493
Here is a sample unit test from the application:
1480
1494
1481
- public class UserAppService_Delete_Tests : UserAppServiceTestBase
1495
+ ``` csharp
1496
+ public class UserAppService_Delete_Tests : UserAppServiceTestBase
1497
+ {
1498
+ [Fact ]
1499
+ public async Task Should_Delete_User ()
1482
1500
{
1483
- [Fact]
1484
- public async Task Should_Delete_User()
1485
- {
1486
- //Arrange
1487
- CreateTestUsers();
1488
-
1489
- var user = await GetUserByUserNameOrNullAsync("artdent");
1490
- user.ShouldNotBe(null);
1491
-
1492
- //Act
1493
- await UserAppService.DeleteUser(new IdInput<long>(user.Id));
1494
-
1495
- //Assert
1496
- user = await GetUserByUserNameOrNullAsync("artdent");
1497
- user.IsDeleted.ShouldBe(true);
1498
- }
1501
+ // Arrange
1502
+ CreateTestUsers ();
1503
+
1504
+ var user = await GetUserByUserNameOrNullAsync (" artdent" );
1505
+ user .ShouldNotBe (null );
1506
+
1507
+ // Act
1508
+ await UserAppService .DeleteUser (new IdInput <long >(user .Id ));
1509
+
1510
+ // Assert
1511
+ user = await GetUserByUserNameOrNullAsync (" artdent" );
1512
+ user .IsDeleted .ShouldBe (true );
1499
1513
}
1514
+ }
1515
+ ```
1500
1516
1501
1517
It creates some users to test and then verifies there is a user named
1502
1518
"artdent". Then it calls the ** DeleteUser** method of the ** user
0 commit comments