Exemple #1
0
 public QuestLogic(IQuestAccess questAccess, ICharacterInfo characterInfo, IInventoryAccess inventoryAccess, ICharacterManager characterManager)
 {
     _questAccess      = questAccess;
     _characterInfo    = characterInfo;
     _inventoryAccess  = inventoryAccess;
     _characterManager = characterManager;
 }
Exemple #2
0
        public async Task AddSkuAsync(string sku)
        {
            Console.WriteLine($"Adding SKU {sku}...");
            IInventoryAccess access = Services.InventoryAccess;
            var item = await access.NewSkuAsync(sku);

            Console.WriteLine($"Raising event for {sku}...");
            IEventPublisher publisher = Services.EventPublisher;
            await publisher.RaiseEvent(Model.SkuMessageType.Added, item);
        }
        public async Task DescribeSkuAsync(string sku, string description)
        {
            Console.WriteLine($"Adding description '{description}' to SKU {sku}...");
            IInventoryAccess access = Services.InventoryAccess;
            var item = await access.SetHumanDescriptionAsync(sku, description);

            Console.WriteLine($"Raising describe event for {sku}...");
            IEventPublisher publisher = Services.EventPublisher;
            await publisher.RaiseEvent(Model.SkuMessageType.DescriptionSet, item);
        }
Exemple #4
0
        public async Task ImageSkuAsync(string sku, string image)
        {
            var imagePath = Path.Combine(Environment.CurrentDirectory, image);

            if (!File.Exists(imagePath))
            {
                throw new Exception($"Image not found at path: {imagePath}.");
            }
            Console.WriteLine($"Adding image '{imagePath}' to SKU {sku}...");
            IInventoryAccess access = Services.InventoryAccess;
            var item = await access.SetImageAsync(sku, File.OpenRead(imagePath));

            Console.WriteLine($"Raising image event for {sku}...");
            IEventPublisher publisher = Services.EventPublisher;
            await publisher.RaiseEvent(Model.SkuMessageType.ImageSet, item);
        }
Exemple #5
0
        public async Task PriceSkuAsync(string sku, string price)
        {
            if (decimal.TryParse(price, out decimal priceParsed))
            {
                Console.WriteLine($"Adding price '{priceParsed}' to SKU {sku}...");
                IInventoryAccess access = Services.InventoryAccess;
                var item = await access.SetPriceAsync(sku, priceParsed);

                Console.WriteLine($"Raising price event for {sku}...");
                IEventPublisher publisher = Services.EventPublisher;
                await publisher.RaiseEvent(Model.SkuMessageType.PriceSet, item);
            }
            else
            {
                throw new ArgumentException($"Unable to parse price {price} for sku {sku}.");
            }
        }
Exemple #6
0
        public async Task GetSkuAsync(string sku)
        {
            IInventoryAccess access = Services.InventoryAccess;
            var item = await access.GetAsync(sku);

            if (item == null)
            {
                Console.WriteLine($"Sku {sku} not found.");
            }
            else
            {
                Console.WriteLine("===");
                Console.WriteLine($"Sku {sku}: {item.Description}.");
                Console.WriteLine(item.DescriptionSet ? "(human validated description)" : "(description not validated)");
                if (item.PriceSet)
                {
                    Console.WriteLine($"Price: {item.Price.ToString("C")}");
                }
                else
                {
                    Console.WriteLine("Price not set.");
                }
                if (item.ImageSet)
                {
                    Console.WriteLine($"Image can be found at:\n{item.ImageUrl}");
                }
                else
                {
                    Console.WriteLine("Image not set.");
                }
                if (item.IsActive)
                {
                    Console.WriteLine("ITEM IS ACTIVE!");
                }
                else
                {
                    Console.WriteLine("This item is not yet active in the catalog.");
                }
                Console.WriteLine("===");
            }
        }
Exemple #7
0
 public InventoryLogic(IInventoryAccess inventoryAccess, ICharacterInfo characterInfo)
 {
     _inventoryAccess = inventoryAccess;
     _characterInfo   = characterInfo;
 }