Exemplo n.º 1
0
 public FiguresController(ILogger <FiguresController> logger, IOrderStorage orderStorage)
 {
     _logger        = logger;
     _orderStorage  = orderStorage;
     _cartConvertor = new CartConvertor();
     _figureCache   = new FigureCache(RedisClient);
 }
Exemplo n.º 2
0
 public AdminCommand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
 {
     _managerInfo       = managementStorage.GetConfig();
     _managementStorage = managementStorage;
     _orderStorage      = orderStorage;
     _adminStorage      = userStorage;
 }
Exemplo n.º 3
0
 public HomeController(IMessageService messageService, IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
 {
     _messageService    = messageService;
     _managementStorage = managementStorage;
     _orderStorage      = orderStorage;
     _adminStorage      = userStorage;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FiguresController"/> class.
 /// </summary>
 /// <param name="orderStorage">Хранилище заказов. реализация IOrderStorage, должна быть зарегистрирована в DI.</param>
 /// <param name="figuresStorage">Хранилище фигур, реализация IFiguresStorage, должна быть зарегистрирована в DI.</param>
 /// <param name="orderValidator">Проверщик заказа. реализация IOrderValidator, должна быть зарегистрирована в DI.</param>
 public FiguresController(
     IOrderStorage orderStorage,
     IFiguresStorage figuresStorage,
     IOrderValidator orderValidator)
 {
     this.orderStorage   = orderStorage;
     this.figuresStorage = figuresStorage;
     this.orderValidator = orderValidator;
 }
        public FiguresController(ILogger <FiguresController> logger, IOrderStorage orderStorage, IFiguresStorage figuresStorage)
        {
            // Сделаем сервис логирования обязательным, раз уж у нас высоконагруженный контроллер/экшен
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            // Без сервиса orderStorage контроллер не сможет выполнять свои функции и, если его не инжектировали, то рушим всё и сразу
            _orderStorage = orderStorage ?? throw new ArgumentNullException(nameof(orderStorage));

            // Вместо ссылки на статический сервис, сделаем его инжектируемым, чтобы в будущем можно было легко протестировать и ничто нам не мешает сделать его как Singleton, но не здесь
            _figuresStorage = figuresStorage ?? throw new ArgumentNullException(nameof(orderStorage));
        }
Exemplo n.º 6
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="OrderSubmitter"/> class.
        /// </summary>
        ///
        /// <param name="configuration">The configuration to use for influencing order submission behavior.</param>
        /// <param name="orderProductionClient">The client to use for interacting with the order production service.</param>
        /// <param name="orderStorage">The storage to use for orders.</param>
        /// <param name="logger">The logger to be used for emitting telemetry from the controller.</param>
        /// <param name="jsonSerializerSettings">The settings to use for JSON serializerion.</param>
        ///
        public OrderSubmitter(OrderSubmitterConfiguration configuration,
                              IOrderProductionClient orderProductionClient,
                              IOrderStorage orderStorage,
                              ILogger logger,
                              JsonSerializerSettings jsonSerializerSettings)
        {
            this.configuration         = configuration ?? throw new ArgumentNullException(nameof(configuration));
            this.orderProductionClient = orderProductionClient ?? throw new ArgumentNullException(nameof(orderProductionClient));
            this.orderStorage          = orderStorage ?? throw new ArgumentNullException(nameof(orderStorage));
            this.Log = logger ?? throw new ArgumentNullException(nameof(logger));
            this.jsonSerializerSettings = jsonSerializerSettings ?? throw new ArgumentNullException(nameof(jsonSerializerSettings));

            this.rng = new Random();
        }
Exemplo n.º 7
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="OrderProcessor"/> class.
        /// </summary>
        ///
        /// <param name="configuration">The configuration to use for influencing order processing behavior.</param>
        /// <param name="ecommerceClient">The client to use for interacting with the eCommerce service.</param>
        /// <param name="orderStorage">The storage to use for orders.</param>
        /// <param name="skuMetadataProcessor">The processor for the metadata associated with a SKU.</param>
        /// <param name="logger">The logger to be used for emitting telemetry from the controller.</param>
        /// <param name="clock">The clock instance to use for date/time related operations.</param>
        /// <param name="jsonSerializerSettings">The settings to use for JSON serializerion.</param>
        ///
        public OrderProcessor(OrderProcessorConfiguration configuration,
                              IEcommerceClient ecommerceClient,
                              IOrderStorage orderStorage,
                              ISkuMetadataProcessor skuMetadataProcessor,
                              ILogger logger,
                              IClock clock,
                              JsonSerializerSettings jsonSerializerSettings)
        {
            this.configuration        = configuration ?? throw new ArgumentNullException(nameof(configuration));
            this.ecommerceClient      = ecommerceClient ?? throw new ArgumentNullException(nameof(ecommerceClient));
            this.orderStorage         = orderStorage ?? throw new ArgumentNullException(nameof(orderStorage));
            this.skuMetadataProcessor = skuMetadataProcessor ?? throw new ArgumentNullException(nameof(skuMetadataProcessor));
            this.Log   = logger ?? throw new ArgumentNullException(nameof(logger));
            this.clock = clock ?? throw new ArgumentNullException(nameof(clock));
            this.jsonSerializerSettings = jsonSerializerSettings ?? throw new ArgumentNullException(nameof(jsonSerializerSettings));

            this.rng = new Random();
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        /// <summary>
        ///   Stores an order as a final order which has completed submission.
        /// </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="createOrderMessage">The CreateOrderMessage representing the order.</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> StoreOrderAsCompletedAsync(ILogger log,
                                                                                  IOrderStorage storage,
                                                                                  CreateOrderMessage order,
                                                                                  string correlationId           = null,
                                                                                  OperationResult emulatedResult = null)
        {
            OperationResult result;

            try
            {
                if (emulatedResult != null)
                {
                    result = emulatedResult;
                }
                else
                {
                    var key = await storage.SaveCompletedOrderAsync(order);

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

                log.Information("Order details for {Partner}//{Order} have been saved as final.  Emulated: {Emulated}.  Result: {Result}",
                                order?.Identity?.PartnerCode,
                                order?.Identity?.PartnerOrderId,
                                (emulatedResult != null),
                                result);
            }

            catch (Exception ex)
            {
                log.Error(ex, "An error occured while saving {Partner}//{Order} as completed submission.", order.Identity.PartnerCode, order.Identity.PartnerOrderId);
                return(OperationResult.ExceptionResult);
            }

            return(result);
        }
Exemplo n.º 10
0
 public OrderRepository(IOrderStorage orderStorage)
 {
     _orderStorage = orderStorage;
 }
Exemplo n.º 11
0
 public OrderSender(IOrderStorage orderStorage, IAdminStorage userStorage)
 {
     _orderStorage = orderStorage;
     _userStorage  = userStorage;
 }
Exemplo n.º 12
0
 public static void InitializeStorage(IOrderStorage storage)
 {
     orders = storage;
 }
Exemplo n.º 13
0
 public ShowPrintsCommand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
     : base(managementStorage, userStorage, orderStorage)
 {
 }
Exemplo n.º 14
0
 public OrderService()
 {
     orderStorage = DependencyService.Get <IOrderStorage>();
 }
Exemplo n.º 15
0
 public RemovePrintCommand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
     : base(managementStorage, userStorage, orderStorage)
 {
 }
 public OrderRepository(IOrderStorage orderStorage, ICurrencyConverter currencyConverter)
 {
     _orderStorage      = orderStorage;
     _currencyConverter = currencyConverter;
 }
Exemplo n.º 17
0
        /// <summary>
        ///   Retrieves an order from pending 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="serializerSettings">The settings to use for JSON serialization operations.</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 <CreateOrderMessage> > RetrievePendingOrderAsync(ILogger log,
                                                                                                       IOrderStorage storage,
                                                                                                       JsonSerializerSettings serializerSettings,
                                                                                                       string partner,
                                                                                                       string orderId,
                                                                                                       string correlationId           = null,
                                                                                                       OperationResult emulatedResult = null)
        {
            OperationResult <CreateOrderMessage> result;

            try
            {
                if (emulatedResult != null)
                {
                    result = new OperationResult <CreateOrderMessage>
                    {
                        Outcome     = emulatedResult.Outcome,
                        Reason      = emulatedResult.Reason,
                        Recoverable = emulatedResult.Recoverable,
                        Payload     = (String.IsNullOrEmpty(emulatedResult.Payload)) ? null : JsonConvert.DeserializeObject <CreateOrderMessage>(emulatedResult.Payload, serializerSettings)
                    };
                }
                else
                {
                    var storageResult = await storage.TryRetrievePendingOrderAsync(partner, orderId);

                    if (!storageResult.Found)
                    {
                        log.Error("Order details for {Partner}//{Order} were not found in the pending order storage. Submission cannot continue. Emulated: {Emulated}.",
                                  partner,
                                  orderId,
                                  (emulatedResult != null));

                        return(new OperationResult <CreateOrderMessage>
                        {
                            Outcome = Outcome.Failure,
                            Reason = FailureReason.OrderNotFoundInPendingStorage,
                            Recoverable = Recoverability.Final,
                        });
                    }

                    result = new OperationResult <CreateOrderMessage>
                    {
                        Outcome     = Outcome.Success,
                        Reason      = String.Empty,
                        Recoverable = Recoverability.Final,
                        Payload     = storageResult.Order
                    };
                }

                log.Information("The order for {Partner}//{Order} was retrieved from pending storage.  Emulated: {Emulated}.  Result: {Result}",
                                partner,
                                orderId,
                                (emulatedResult != null),
                                result);
            }

            catch (Exception ex)
            {
                log.Error(ex, "An error occured while retrieving {Partner}//{Order} as pending submission.", partner, orderId);
                return(OperationResult <CreateOrderMessage> .ExceptionResult);
            }

            return(result);
        }
Exemplo n.º 18
0
 public GetPhoneNumberCommand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
     : base(managementStorage, userStorage, orderStorage)
 {
 }
Exemplo n.º 19
0
 public FormOrderCommand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
     : base(managementStorage, userStorage, orderStorage)
 {
 }
Exemplo n.º 20
0
 public OrderController(IOrderStorage orderStorage, SessionCartStorage sessionCartStorage)
 {
     _orderStorage       = orderStorage;
     _sessionCartStorage = sessionCartStorage;
 }
Exemplo n.º 21
0
 public GetAddressComand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
     : base(managementStorage, userStorage, orderStorage)
 {
 }
Exemplo n.º 22
0
 public OrderService(IOrderStorage storage)
 {
     _storage = storage;
 }
Exemplo n.º 23
0
        private readonly IFigureStorage _figureStorage;         // хранилище фигур

        public FiguresController(ILogger <FiguresController> logger, IOrderStorage orderStorage, IFigureStorage figureStorage)
        {
            _logger        = logger;
            _orderStorage  = orderStorage;
            _figureStorage = figureStorage;
        }
Exemplo n.º 24
0
 public OrderRepository(IOrderStorage storage)
 {
     _storage = storage;
 }
 public OrderLogic(IOrderStorage orderStorage)
 {
     _orderStorage = orderStorage;
 }
Exemplo n.º 26
0
 public GetNameCommand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
     : base(managementStorage, userStorage, orderStorage)
 {
 }
Exemplo n.º 27
0
 public ChooseTypeCommand(IManagementStorage managementStorage, IAdminStorage userStorage, IOrderStorage orderStorage)
     : base(managementStorage, userStorage, orderStorage)
 {
 }
Exemplo n.º 28
0
 public OrderService(IFiguresStorage figuresStorage, IOrderStorage orderStorage)
 {
     _figuresStorage = figuresStorage;
     _orderStorage   = orderStorage;
 }