public SiccarStatusCacheResponse BuildSiccarStatusCacheResponseForUser(string userId) { var responses = new List <SiccarStatusCacheProcessResponse>(); var schemas = _processSchemaCache.GetSchemas(userId); foreach (var schema in schemas) { var attributes = new List <KeyValuePair <string, string> >(); // The first tx is actually the last the way the results from the server var authorisedTransaction = schema.stepStatuses[0].stepTransactionId; if (authorisedTransaction != null) { var fatributes = _siccarTransactionCache.GetTransaction(authorisedTransaction).Attributes; attributes.AddRange(fatributes); // Only add the last transactions if the first ones have been added var userApplicationTransaction = schema.stepStatuses[schema.stepStatuses.Count - 1].stepTransactionId; if (userApplicationTransaction != null) { var uatributes = _siccarTransactionCache.GetTransaction(userApplicationTransaction).Attributes; attributes.AddRange(uatributes); } } var status = GetStatusOfProcess(schema, userId); var atrs = attributes.ToHashSet().ToList(); var schemaId = schema.schemaId; var statusCacheResponse = new SiccarStatusCacheProcessResponse(schemaId, status, atrs); responses.Add(statusCacheResponse); } var response = new SiccarStatusCacheResponse() { ProgressReports = _progressReportCache.GetReport(userId), ProcessResponses = responses.ToHashSet() }; return(response); }
public SiccarStatusCacheResponseViewModel(SiccarStatusCacheResponse parent) { this.ProgressReports = parent.ProgressReports.Select(x => new ProgressReportViewModel(x)).ToHashSet(); this.ProcessResponses = parent.ProcessResponses.Select(x => new SiccarStatusCacheProcessResponseViewModel(x)).ToHashSet(); }