コード例 #1
0
        public async Task <dynamic> SaveCrMtoSfErrorResponseAsync(
            [Metadata("Error", "Error Body")][FromBody] CrmErrorResponse error)
        {
            _client = new DocumentClient(new Uri(DocumentDbContext.EndPoint), DocumentDbContext.AuthKey);

            var collectionLink = UriFactory.CreateDocumentCollectionUri(DocumentDbContext.DatabaseId,
                                                                        DocumentDbContext.CollectionId);

            dynamic errorMessage = new
            {
                id        = error.PatientId + "-" + Math.Truncate(Utility.ConvertToTimestamp(DateTime.UtcNow)),
                patientId = error.PatientId,
                timestamp = DateTime.UtcNow,
                action    = error.Action,
                body      = error.Message,
                source    = error.Source,
                code      = error.StatusCode,
                errors    = error.Errors,
                isError   = error.IsError,
                severity  = error.Severity,
                notes     = error.Notes,
                resolved  = error.Resolved
            };

            ResourceResponse <Document> response =
                await _client.CreateDocumentAsync(collectionLink, errorMessage, disableAutomaticIdGeneration : true);

            var createdDocument = response.Resource;

            return(createdDocument);
        }
コード例 #2
0
        public async Task <ActionResult> EditAsync(
            [Bind(Include = "Id,prescriberId,notes,resolved")] CrmErrorResponse item)
        {
            if (!ModelState.IsValid)
            {
                return(View(item));
            }
            await DocumentDbRepository <CrmErrorResponse> .UpdateItemAsync(item.Id, item);

            return(RedirectToAction("Index"));
        }