public async Task <Result <ProductQueue> > UpdateToPreparing(ProductQueue productQueue)
        {
            _serviceScopefactory = productQueue._serviceScopefactory;
            var result = await this.UpdateToStatus(ProductOrderStatus.Preparing, OrderStatusEnum.Preparing, productQueue);

            return(result);
        }
Exemplo n.º 2
0
        public static void Main()
        {
            Console.WriteLine(nameof(Subscriber).ToUpper());

            IProductQueue productQueue = new ProductQueue(new Connection("localhost", 5672, "admin", "P4ssW0rd!"));

            productQueue.Subscribe(product => Console.WriteLine(product.Name));
        }
Exemplo n.º 3
0
        public UpdateContext(ILifetimeScope lifetimeScope)
        {
            _lifetimeScope = lifetimeScope;

            Vendors  = new VendorQueue();
            Products = new ProductQueue();
            Offers   = new OfferQueue();
        }
Exemplo n.º 4
0
        public static void Main()
        {
            Console.WriteLine(nameof(Subscriber).ToUpper());

            IProductQueue productQueue = new ProductQueue();

            productQueue.Subscribe(product => Console.WriteLine(product.Name));

            Console.ReadLine();
        }
        public void SetCommand(string command, ProductQueue productQueue)
        {
            switch (command)
            {
            case string s when s.ToLower().Contains("preparing"):
                productQueue._serviceScopefactory = _serviceProvider;

                _workQueue.AddCommand(new PrepareProductOrder(productQueue));
                break;

            case string s when s.ToLower().Contains("done"):
                productQueue._serviceScopefactory = _serviceProvider;

                _workQueue.AddCommand(new ProductDone(productQueue));
                break;
            }
        }
Exemplo n.º 6
0
        public static void Main()
        {
            Console.WriteLine(nameof(Publisher).ToUpper());

            while (true)
            {
                Console.Write("Enter the product name: ");

                var name = Console.ReadLine();

                var product = new Product {
                    Name = name
                };

                IProductQueue productQueue = new ProductQueue();

                productQueue.Publish(product);
            }
        }
Exemplo n.º 7
0
        public static void Main()
        {
            Console.WriteLine(nameof(Publisher).ToUpper());

            IProductQueue productQueue = new ProductQueue(new Connection("localhost", 5672, "admin", "P4ssW0rd!"));

            while (true)
            {
                Console.Write("Enter the product name: ");

                var name = Console.ReadLine();

                var product = new Product {
                    Name = name
                };

                productQueue.Publish(product);
            }
        }
        public async Task <Result <ProductQueue> > UpdateToDone(ProductQueue productQueue)
        {
            try{
                _serviceScopefactory = productQueue._serviceScopefactory;

                using (var scope = _serviceScopefactory.CreateScope())
                {
                    var _productOrderService = scope.ServiceProvider.GetService <IProductOrderService>();


                    var result = await _productOrderService.GetByOrderAndProductId(productQueue.Id, productQueue.OrderId, productQueue.ProductId);

                    if (result)
                    {
                        var updatedDate = DateTime.Now;
                        result.Value.ProductQueueStatus = ProductOrderStatus.Done;
                        result.Value.UpdatedAt          = updatedDate;

                        var updateProductOrder = await _productOrderService.Update(result.Value);

                        if (updateProductOrder.IsSuccess)
                        {
                            return(Result.Ok(productQueue));
                        }

                        return(Result.Fail <ProductQueue>("Error while updating ProductOrder entity", ResultCode.BadRequest));
                    }

                    return(Result.Fail <ProductQueue>("No ProductOrder entity was found with given ID", ResultCode.BadRequest));
                }
            }
            catch (Exception ex)
            {
                return(Result.Fail <ProductQueue>(ex.Message, ResultCode.InternalServerError));
            }
        }
 public ProductDone(ProductQueue productQueue)
 {
     _productQueue = productQueue;
 }
Exemplo n.º 10
0
 public PrepareProductOrder(ProductQueue productQueue)
 {
     _productQueue = productQueue;
 }