Ejemplo n.º 1
0
        private async Task CreateProductOrder(Guid customerId, OrderProductDetail orderProductDetail)
        {
            await _sqlService.CreateOrder(orderProductDetail.Code, customerId, orderProductDetail.Quantity);

            await _sqlService.UpdateProductQuantity(orderProductDetail.Code, orderProductDetail.Quantity);

            // Only for the demo product check if we need to switch the video
            if (orderProductDetail.Code == Constants.DemoProductId)
            {
                try
                {
                    var deviceState = await _ioTCentralService.GetDeviceState();

                    var videoPathDesiredValue = deviceState.Manage.Metadata.VideoPath.DesiredValue;
                    if (string.Equals(videoPathDesiredValue, Constants.StockedShelf, StringComparison.OrdinalIgnoreCase))
                    {
                        await _ioTCentralService.SetVideoPathProperty(Constants.LowStockedShelf);
                    }
                }
                catch (Exception e)
                {
                    throw new Exception($"Can't update desired property: {e.Message}");
                }
            }
        }