本文整理汇总了C#中IOwinContext.GetRouteValue方法的典型用法代码示例。如果您正苦于以下问题:C# IOwinContext.GetRouteValue方法的具体用法?C# IOwinContext.GetRouteValue怎么用?C# IOwinContext.GetRouteValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOwinContext
的用法示例。
在下文中一共展示了IOwinContext.GetRouteValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUserDetails
private async Task GetUserDetails(IOwinContext context)
{
var key = new UserKey(context.GetRouteValue("key"));
var user = _collectionsReadModel.Users.Single(r => r.Key == key);
await context.WriteJson(user, _settings);
}
示例2: GetRoleDetails
private async Task GetRoleDetails(IOwinContext context)
{
var key = new RoleKey(context.GetRouteValue("key"));
var role = _collectionsReadModel.Roles.Single(r => r.Key == key);
await context.WriteJson(role, _settings);
}
示例3: GetPermissionDetails
private async Task GetPermissionDetails(IOwinContext context)
{
var key = new PermissionKey(context.GetRouteValue("key"));
var permission = _collectionsReadModel.Permissions.Single(p => p.Key == key);
await context.WriteJson(permission, _settings);
}
示例4: UpdateRoleName
private async Task UpdateRoleName(IOwinContext context)
{
var key = new RoleKey(context.GetRouteValue("key"));
var dto = context.ReadJson<EditRoleDto>();
var role = _collectionsReadModel.Roles.Single(r => r.Key == key);
_mediator.Publish(new ChangeRoleNameCommand(
context.GetOperator(),
role.ID,
dto.Name
));
await Task.Yield();
}
示例5: UpdatePermissionName
private async Task UpdatePermissionName(IOwinContext context)
{
var key = new PermissionKey(context.GetRouteValue("key"));
var dto = context.ReadJson<EditPermissionDto>();
var permission = _collectionsReadModel.Permissions.Single(p => p.Key == key);
_mediator.Publish(new ChangePermissionNameCommand(
context.GetOperator(),
permission.ID,
dto.Name
));
await Task.Yield();
}
示例6: RemovePermissions
private async Task RemovePermissions(IOwinContext context)
{
var key = new RoleKey(context.GetRouteValue("key"));
var role = _collectionsReadModel.Roles.Single(r => r.Key == key);
var permissions = context
.ReadJson<PermissionKey[]>()
.Select(pk => _collectionsReadModel.Permissions.Single(p => p.Key == pk))
.Select(p => p.ID);
_mediator.Publish(new RemovePermissionsFromRoleCommand(
context.GetOperator(),
role.ID,
permissions
));
await Task.Yield();
}
示例7: UpdateUserName
private async Task UpdateUserName(IOwinContext context)
{
var key = new UserKey(context.GetRouteValue("key"));
var dto = context.ReadJson<EditUserDto>();
var user = _collectionsReadModel.Users.Single(r => r.Key == key);
_mediator.Publish(new ChangeUserNameCommand(
context.GetOperator(),
user.ID,
dto.Name
));
await Task.Yield();
}
示例8: CheckPermission
private async Task CheckPermission(IOwinContext context)
{
var userKey = new UserKey(context.GetRouteValue("user-key"));
var permissionKey = new PermissionKey(context.GetRouteValue("permission-key"));
var user = _collectionsReadModel.Users.Single(u => u.Key == userKey);
var permission = _collectionsReadModel.Permissions.Single(p => p.Key == permissionKey);
var result = new
{
Allowed = _authReadModel.CanUserPerformAction(user.ID, permission.ID)
};
await context.WriteJson(result, _settings);
}
示例9: RemoveRole
private async Task RemoveRole(IOwinContext context)
{
var key = new UserKey(context.GetRouteValue("key"));
var user = _collectionsReadModel.Users.Single(r => r.Key == key);
var permissions = context
.ReadJson<RoleKey[]>()
.Select(rk => _collectionsReadModel.Roles.Single(p => p.Key == rk))
.Select(r => r.ID);
_mediator.Publish(new RemoveRolesFromUserCommand(
context.GetOperator(),
user.ID,
permissions
));
await Task.Yield();
}
示例10: AddRevoke
private async Task AddRevoke(IOwinContext context)
{
var key = new UserKey(context.GetRouteValue("key"));
var user = _collectionsReadModel.Users.Single(r => r.Key == key);
var permissions = context
.ReadJson<PermissionKey[]>()
.Select(pk => _collectionsReadModel.Permissions.Single(p => p.Key == pk))
.Select(p => p.ID);
_mediator.Publish(new AddRevokesToUserCommand(
context.GetOperator(),
user.ID,
permissions
));
await Task.Yield();
}