public IResult Handle(GetShopItemsQuery query)
        {
            var items = DatabaseQueryProcessor.GetProducts();

            var shopItemsDto = new ShopItemDto[items.Count];

            for (var i = 0; i < items.Count; i++)
            {
                shopItemsDto[i]             = new ShopItemDto();
                shopItemsDto[i].key         = items[i].productId;
                shopItemsDto[i].name        = items[i].name;
                shopItemsDto[i].price       = items[i].price;
                shopItemsDto[i].img         = items[i].imagePath;
                shopItemsDto[i].description = items[i].description;
                shopItemsDto[i].type        = items[i].productType;
            }

            return(new ShopItemsDto()
            {
                isSuccess = true,
                shopItems = shopItemsDto
            });
        }
        public IResult Handle(AddOrderCommand command)
        {
            int clientId = SessionRepository.GetClientIdOfSession(command.sessionToken);

            if (clientId == -1)
            {
                throw new Exception();
            }

            var address = DatabaseQueryProcessor.GetAddress(
                clientId,
                command.address.country,
                command.address.city,
                command.address.street,
                command.address.ZIPCode,
                command.address.buildingNumber,
                command.address.apartmentNumber
                );

            if (address == null)
            {
                throw new Exception();
            }

            var products   = DatabaseQueryProcessor.GetProducts();
            var totalPrice = 0;

            foreach (var orderEntry in command.orderEntries)
            {
                var foundProducts = products.FindAll(p => p.name == orderEntry.name);
                if (foundProducts.Count != 1)
                {
                    throw new Exception();
                }

                totalPrice += foundProducts[0].price / 100 * orderEntry.quantity;
            }

            if (totalPrice.ToString("F", CultureInfo.InvariantCulture) != command.totalPrice)
            {
                throw new Exception();
            }

            var orderId = DatabaseQueryProcessor.CreateNewOrder(
                clientId,
                0,
                address.addressId,
                0,
                DateTime.Now.ToString("yyyy-MM-dd")
                );

            foreach (var orderEntry in command.orderEntries)
            {
                var foundProducts = products.FindAll(p => p.name == orderEntry.name);

                DatabaseQueryProcessor.CreateNewOrderEntry(
                    orderId,
                    foundProducts[0].productId,
                    orderEntry.quantity
                    );
            }

            return(new SuccessInfoDto()
            {
                isSuccess = true
            });
        }