public async Task <(bool, OperationDto)> TrySetAsync(string id, string ownUserId, string name, OperationState state, string code = null, string reason = null, string projectId = null, string issueId = null, string sprintId = null, string userId = null) { var operation = await GetAsync(id); if (operation is null) { operation = new OperationDto(); } else if (operation.State == OperationState.Completed || operation.State == OperationState.Rejected) { return(false, operation); } operation.Id = id; operation.OwnUserId = ownUserId ?? string.Empty; operation.Name = name; operation.State = state; operation.Code = code ?? string.Empty; operation.Reason = reason ?? string.Empty; operation.ProjectId = projectId ?? string.Empty; operation.IssueId = issueId ?? string.Empty; operation.SprintId = sprintId ?? string.Empty; operation.UserId = userId ?? string.Empty; await _cache.SetStringAsync(GetKey(id), JsonConvert.SerializeObject(operation), new DistributedCacheEntryOptions { SlidingExpiration = TimeSpan.FromSeconds(_options.ExpirySeconds) }); OperationUpdated?.Invoke(this, new OperationUpdatedEventArgs(operation)); return(true, operation); }
public async Task PublishOperationUpdatedAsync(OperationUpdated @event) => await PublishToUserAsync(@event.UserId, "operation_updated", new { requestId = @event.RequestId, name = @event.Name, state = @event.State, code = @event.Code, message = @event.Message } );