internal bool InitRoleEntity() { if (_IsFailure) { return(false); } if (RoleEntity != null) { return(true); } RouteData routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current)); EntityRoute route = routeData.Route as EntityRoute; if (route == null) { _IsFailure = true; return(false); } RoleEntity = Resolve(route.UserType, Identity.Name); if (RoleEntity == null) { _IsFailure = true; return(false); } return(true); }
public async Task SaveAsync(IRoleEntity roleEntity) { if (!(roleEntity is RoleEntity role)) { role = (RoleEntity) await GetAsync(roleEntity.RowKey) ?? new RoleEntity(); role.ETag = roleEntity.ETag; role.Name = roleEntity.Name; role.KeyValues = roleEntity.KeyValues; } role.PartitionKey = RoleEntity.GeneratePartitionKey(); role.RowKey = roleEntity.RowKey; await _tableStorage.InsertOrMergeAsync(role); }
internal bool InitRoleEntity() { if (_IsFailure) return false; if (RoleEntity != null) return true; RouteData routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current)); EntityRoute route = routeData.Route as EntityRoute; if (route == null) { _IsFailure = true; return false; } RoleEntity = Resolve(route.UserType, Identity.Name); if (RoleEntity == null) { _IsFailure = true; return false; } return true; }
public async Task SaveAsync(IRoleEntity roleEntity) { if (roleEntity is RoleEntity role) { role.PartitionKey = RoleEntity.GeneratePartitionKey(); role.RowKey = roleEntity.RoleId; } else { var pk = RoleEntity.GeneratePartitionKey(); var rk = RoleEntity.GenerateRowKey(roleEntity.RoleId); role = await _tableStorage.GetDataAsync(pk, rk) ?? new RoleEntity { PartitionKey = pk, RowKey = rk }; role.RoleId = roleEntity.RoleId; role.Name = roleEntity.Name; role.KeyValues = roleEntity.KeyValues; } await _tableStorage.InsertOrMergeAsync(role); }