Esempio n. 1
0
        /// <summary>
        ///   Deletes an order from the pending submission storage.
        /// </summary>
        ///
        /// <param name="log">The logging instance to use for emitting information.</param>
        /// <param name="storage">The storage to use for the order.</param>
        /// <param name="partner">The partner associated with the order.</param>
        /// <param name="orderId">The unique identifier of the order to retrieve the detials of.</param>
        /// <param name="correlationId">An optional identifier used to correlate activities across the disparate parts of processing, including external interations.</param>
        /// <param name="emulatedResult">An optional emulated result to use in place of interacting with storage.</param>
        ///
        /// <returns>The result of the operation.</returns>
        ///
        protected virtual async Task <OperationResult> DeletePendingOrderAsync(ILogger log,
                                                                               IOrderStorage storage,
                                                                               string partner,
                                                                               string orderId,
                                                                               string correlationId           = null,
                                                                               OperationResult emulatedResult = null)
        {
            OperationResult result;

            try
            {
                if (emulatedResult != null)
                {
                    result = emulatedResult;
                }
                else
                {
                    await storage.DeletePendingOrderAsync(partner, orderId);

                    result = new OperationResult
                    {
                        Outcome     = Outcome.Success,
                        Reason      = String.Empty,
                        Recoverable = Recoverability.Final,
                        Payload     = String.Empty
                    };
                }

                log.Information("Order for {Partner}//{Order} has been deleted from the storage for pending sumbissions.  Emulated: {Emulated}.  Result: {Result}",
                                partner,
                                orderId,
                                (emulatedResult != null),
                                result);
            }

            catch (Exception ex)
            {
                log.Error(ex, "An error occured while depeting {Partner}//{Order} from pending submissions.", partner, orderId);
                return(OperationResult.ExceptionResult);
            }

            return(result);
        }