示例#1
0
 private static PullRequest MapToDomain(PullRequestDao dao)
 {
     return(new PullRequest
     {
         Id = Convert.ToInt32(dao.RowKey),
         Number = dao.Number ?? 0,
         Title = dao.Title,
         Url = string.IsNullOrEmpty(dao.Url)
             ? null
             : new Uri(dao.Url),
         Status = (PullRequestStatus)Enum.Parse(typeof(PullRequestStatus), dao.Status, true),
         RepositoryName = dao.RepositoryName,
         RepositoryUrl = string.IsNullOrEmpty(dao.RepositoryUrl)
             ? null
             : new Uri(dao.RepositoryUrl),
         CreatedAt = dao.CreatedAt ?? DateTimeOffset.MinValue,
         UpdatedAt = dao.UpdatedAt ?? DateTimeOffset.MinValue,
         ClosedAt = dao.ClosedAt
     });
 }
示例#2
0
        public async Task Upsert(string organisation, PullRequest pullRequest)
        {
            var entity = new PullRequestDao
            {
                PartitionKey   = organisation.ToLowerInvariant(),
                RowKey         = pullRequest.Id.ToString(),
                Number         = pullRequest.Number,
                Title          = pullRequest.Title,
                Timestamp      = DateTimeOffset.Now,
                Url            = pullRequest.Url.ToString(),
                CreatedAt      = pullRequest.CreatedAt,
                UpdatedAt      = pullRequest.UpdatedAt,
                ClosedAt       = pullRequest.ClosedAt,
                Status         = pullRequest.Status.ToString(),
                RepositoryName = pullRequest.RepositoryName,
                RepositoryUrl  = pullRequest.RepositoryUrl.ToString()
            };

            var table = await _azureStorage.GetTable(PullRequestsTable);

            await table.ExecuteAsync(TableOperation.InsertOrReplace(entity));
        }