Example #1
0
        /// <summary>
        /// Gets the results of a submit request.
        /// </summary>
        /// <param name="asyncResult">An asynchronous result that identifies a submit request.</param>
        /// <returns>The results returned by the submit request.</returns>
        public SubmitCompletedResult EndSubmit(IAsyncResult asyncResult)
        {
            DomainClientAsyncResult domainClientResult = this.EndAsyncResult(asyncResult, AsyncOperationType.Submit, false /* cancel */);
            SubmitCompletedResult   submitResults      = this.EndSubmitCore(domainClientResult.InnerAsyncResult);

            // correlate the operation results back to their actual client entity references
            Dictionary <int, Entity> submittedEntities = domainClientResult.EntityChangeSet.GetChangeSetEntries().ToDictionary(p => p.Id, p => p.Entity);

            foreach (ChangeSetEntry op in submitResults.Results)
            {
                op.ClientEntity = submittedEntities[op.Id];
            }

            return(submitResults);
        }
        protected override SubmitCompletedResult EndSubmitCore(IAsyncResult asyncResult)
        {
            MockAsyncResult ar = (MockAsyncResult)asyncResult;
            object[] stateParts = (object[])ar.InnerState;
            EntityChangeSet changeSet = (EntityChangeSet)stateParts[0];
            IEnumerable<ChangeSetEntry> submitOperations = (IEnumerable<ChangeSetEntry>)stateParts[1];

            SubmitCompletedResult submitResults = new SubmitCompletedResult(changeSet, submitOperations);

            return submitResults;
        }
        protected override SubmitCompletedResult EndSubmitCore(IAsyncResult asyncResult)
        {
            // Maybe assert expected type
            if (this.Error != null)
            {
                throw this.Error;
            }

            this.Submitted = true;

            AdcSubmitAsyncResult result = asyncResult as AdcSubmitAsyncResult;
            result.SubmitOperations.First().Entity = result.User;
            result.Submit(this.SubmitConflictMembers, this.SubmitErrors, this.SubmitValidationErrors);
            SubmitCompletedResult results = new SubmitCompletedResult(result.ChangeSet, result.SubmitOperations);
            return results;
        }