public async Task <Unit> Handle(StaticMeshPatchCommand request, CancellationToken cancellationToken) { var canOperate = await clientAssetPermissionControlService.CanEditClientAsset(); if (!canOperate) { throw new HttpForbiddenException(); } var staticMesh = await staticMeshRepository.FindAsync(request.Id); if (staticMesh == null) { throw new HttpResourceNotFoundException(commonLocalizer["HttpRespond.NotFound", "StaticMesh", request.Id]); } mapper.Map(staticMesh, request); request.ApplyPatch(); var modifier = identityService.GetUserId(); staticMesh.UpdateBasicInfo(request.Name, modifier); await staticMeshRepository.UpdateAsync(staticMesh); return(Unit.Value); }
public async Task <StaticMeshIdentityQueryDTO> Handle(StaticMeshIdentityQuery request, CancellationToken cancellationToken) { var staticMesh = await staticMeshRepository.FindAsync(request.Id); if (staticMesh == null) { throw new HttpResourceNotFoundException(commonLocalizer["HttpRespond.NotFound", "StaticMesh", request.Id]); } return(mapper.Map <StaticMeshIdentityQueryDTO>(staticMesh)); }
public async Task Handle(ProductSpecCreatedEvent notification, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(notification.SourcedStaticMeshId)) { return; } var mesh = await staticMeshRepository.FindAsync(notification.SourcedStaticMeshId); mesh.SignRelatedProductSpec(notification.Id); await staticMeshRepository.UpdateAsync(mesh); }
public async Task Handle(DeleteProductSpecRelatedStaticMeshEvent notification, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(notification.StaticMeshIds)) { return; } var idArr = notification.StaticMeshIds.Split(",", StringSplitOptions.RemoveEmptyEntries); foreach (var id in idArr) { var data = await staticMeshRepository.FindAsync(id); await staticMeshRepository.DeleteAsync(data, string.Empty); } }
public async Task <ObjectResult> Handle(StaticMeshBatchDeleteCommand request, CancellationToken cancellationToken) { var canOperate = await clientAssetPermissionControlService.CanEditClientAsset(); if (!canOperate) { throw new HttpForbiddenException(); } var result = new MultiStatusObjectResult(); var operatorId = identityService.GetUserId(); var resourcePartUri = uriService.GetUriWithoutQuery().URIUpperLevel(); var idArr = request.Ids.Split(",", StringSplitOptions.RemoveEmptyEntries); for (int i = 0, len = idArr.Count(); i < len; i++) { var id = idArr[i]; var uri = $"{resourcePartUri}/{id}"; var data = await staticMeshRepository.FindAsync(id); if (data == null) { result.AddResult(uri, 404, ""); continue; } //var query = await userManagedAccountService.GetManagedAccounts(operatorId); //var canOperat = await query.AnyAsync(x => x.Id == accountId); //if (!canOperat) //{ // result.AddResult(uri, 403, localizer["OperateForbidden"]); // continue; //} await staticMeshRepository.DeleteAsync(data, operatorId); result.AddResult(uri, 200, ""); } return(result.Transfer()); }