public static ReportRowEntity Create <T>(KycReportType reportType, T rowObj, string rowId)
        {
            var jsonRow = JsonConvert.SerializeObject(rowObj, Formatting.None, new JsonSerializerSettings
            {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });

            return(new ReportRowEntity()
            {
                PartitionKey = GeneratePartitionKey(reportType),
                RowKey = rowId,
                Timestamp = DateTimeOffset.UtcNow,

                ReportType = reportType,
                JsonRow = jsonRow
            });
        }
        public async Task <IEnumerable <string> > GetJsonData(KycReportType reportType, bool isDescending = false, IEnumerable <string> rowKeys = null)
        {
            string partitionKey;

            switch (reportType)
            {
            case KycReportType.KycReportDailyLeadership:
                partitionKey = ReportRowEntity.GeneratePartitionKey(KycReportType.KycReportDailyLeadership);
                break;

            default:
                partitionKey = null;
                break;
            }


            if (!string.IsNullOrWhiteSpace(partitionKey))
            {
                IEnumerable <ReportRowEntity> data;
                if (rowKeys == null)
                {
                    data = await _tableStorage.GetDataAsync(partitionKey);
                }
                else
                {
                    data = await _tableStorage.GetDataAsync(partitionKey, rowKeys);
                }

                var jsonRows = isDescending
                    ? data.OrderByDescending(d => d.Timestamp).Select(d => d.JsonRow)
                    : data.Select(d => d.JsonRow);

                //var jsonReport = $"[\r\n{string.Join(", \r\n", jsonRows)}\r\n]";

                return(jsonRows);
            }

            return(new List <string>());
        }
 public static string GeneratePartitionKey(KycReportType reportType)
 {
     return($"REP_{reportType}");
 }