private async Task <DialogTurnResult> SwitchSummaryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _switchmodel = new BitrixProductRowModel(); var _switchlicense = new BitrixProductRowModel(); var _Basket = await _botAccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel(), cancellationToken); var _current_rate = _Basket.currentRate; var _licenseduration = _Basket.licenseDuration; var _title = stepContext.Values["switchmodel"].ToString(); var _strippedsku = ProductUtil.generateSKU(_title); var _quantity = stepContext.Result.ToString(); //return to menu if the sku wasnt found var _licenseparam = $"{_strippedsku}-{_licenseduration}"; //await stepContext.Context.SendActivityAsync(_licenseparam); var _switchdata = await WebServicesFactory.QueryProductData(_title, "LIC"); var _switchlicensedata = await WebServicesFactory.QueryProductData(_licenseparam, "HW"); //await stepContext.Context.SendActivityAsync(MessageFactory.Text("sku" + _switchlicensedata.listJurumaniCloudInventory_Models.Items[0].SKU)); if (_switchdata.listJurumaniCloudInventory_Models.Items.Count == 0) { await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Product {_title} wasn't found in the catalog")); } else { var _price = double.Parse(_switchdata.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD) * _current_rate; _switchmodel.PRICE = _price; _switchmodel.PRODUCT_NAME = _title; _switchmodel.QUANTITY = _quantity; _switchlicense.PRICE = float.Parse(_switchlicensedata.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD) * _current_rate; _switchlicense.QUANTITY = _quantity; _switchlicense.PRODUCT_NAME = _switchlicensedata.listJurumaniCloudInventory_Models.Items[0].SKU; await stepContext.PromptAsync(nameof(NumberPrompt <int>), new PromptOptions { Prompt = MessageFactory.Text($"You ordered {stepContext.Result}x {stepContext.Values["switchmodel"]}s at R{_price} each") }); _Basket.products.Add(_switchmodel); _Basket.products.Add(_switchlicense); await _botAccessors.QuoteBasket.SetAsync(stepContext.Context, _Basket, cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text(_Basket.ToString())); } return(await stepContext.ReplaceDialogAsync("AddMoreDevicesDialog")); }
private async Task <DialogTurnResult> FirewallSummaryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _Basket = await _botAccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel(), cancellationToken); var _current_rate = _Basket.currentRate; var _licensduration = _Basket.licenseDuration; var _firewalllicensetype = stepContext.Values["firewalllicensetype"].ToString(); var _firewallmodel = new BitrixProductRowModel(); var _firewalllicense = new BitrixProductRowModel(); var _title = (string)stepContext.Values["firewallmodel"]; var _quantity = stepContext.Result.ToString(); //add function to request the price of the model _title = ProductUtil.generateSKU(_title); var _licensesku = $"LIC-{_title}-{_firewalllicensetype}-{_licensduration}"; // await stepContext.Context.SendActivityAsync(MessageFactory.Text(_licensesku)); var _firewalldata = await WebServicesFactory.QueryProductData(_title, "LIC"); var _firewalllicensedata = await WebServicesFactory.QueryProductData(_licensesku, "HW"); if (_firewalldata.listJurumaniCloudInventory_Models.Items.Count == 0) { await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Product {_title} was not found")); } else { var _price = double.Parse(_firewalldata.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD); await stepContext.PromptAsync(nameof(NumberPrompt <int>), new PromptOptions { Prompt = MessageFactory.Text($"You ordered {_quantity}x {_title} at R{_price*_current_rate} each") }); _firewallmodel.PRICE = _price * _current_rate; _firewallmodel.QUANTITY = _quantity; _firewallmodel.PRODUCT_NAME = _title; _firewalllicense.PRICE = double.Parse(_firewalllicensedata.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD) * _current_rate; _firewalllicense.PRODUCT_NAME = _firewalllicensedata.listJurumaniCloudInventory_Models.Items[0].SKU; _firewalllicense.QUANTITY = _quantity; _Basket.products.Add(_firewallmodel); _Basket.products.Add(_firewalllicense); await _botAccessors.QuoteBasket.SetAsync(stepContext.Context, _Basket, cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text(_Basket.ToString())); } return(await stepContext.ReplaceDialogAsync("AddMoreDevicesDialog")); }
private async Task <DialogTurnResult> FirewallSummaryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _firewallmodel = new BitrixProductRowModel(); var _title = (string)stepContext.Values["firewallmodel"]; var _quantity = Int32.Parse(stepContext.Result.ToString()); await stepContext.PromptAsync(nameof(NumberPrompt <int>), new PromptOptions { Prompt = MessageFactory.Text($"You ordered {stepContext.Result}x {stepContext.Values["firewallmodel"]}") }); var Basket = await _botaccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel(), cancellationToken); Basket.products.Add(_firewallmodel); await stepContext.Context.SendActivityAsync(MessageFactory.Text(Basket.ToString())); return(await stepContext.ReplaceDialogAsync(nameof(AddMoreDevicesDialog))); }
private async Task <DialogTurnResult> CameraSummaryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _Basket = await _botAccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel(), cancellationToken); var _current_rate = _Basket.currentRate; var _licenseduration = _Basket.licenseDuration; var _licensesku = $"LIC-MV-{_licenseduration}"; var _cameramodel = new BitrixProductRowModel(); var _cameralicense = new BitrixProductRowModel(); var _title = (string)stepContext.Values["cameramodel"]; var _quantity = float.Parse(stepContext.Result.ToString()); _cameramodel.PRODUCT_NAME = _title; _cameramodel.QUANTITY = _quantity.ToString(); var _cameraresponse = await WebServicesFactory.QueryProductData(_title, "LIC"); var _cameralicensedata = await WebServicesFactory.QueryProductData(_licensesku, "HW"); //convert the usd price to zar var camera_zar_price = double.Parse(_cameraresponse.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD) * _current_rate; await stepContext.Context.SendActivityAsync(MessageFactory.Text($"The camera price is {_cameraresponse.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD}")); var camera_license_price = double.Parse(_cameralicensedata.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD) * _current_rate; _cameramodel.PRICE = camera_zar_price; _cameralicense.PRODUCT_NAME = _licensesku; _cameralicense.PRICE = camera_license_price; _cameralicense.QUANTITY = _quantity.ToString(); //calculate the zar equivalence of the license price await stepContext.PromptAsync(nameof(NumberPrompt <int>), new PromptOptions { Prompt = MessageFactory.Text($"You ordered {stepContext.Result}x {stepContext.Values["cameramodel"]} at R{camera_zar_price} each") }); _Basket.products.Add(_cameramodel); _Basket.products.Add(_cameralicense); await _botAccessors.QuoteBasket.SetAsync(stepContext.Context, _Basket, cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text(_Basket.ToString())); return(await stepContext.ReplaceDialogAsync("AddMoreDevicesDialog")); }
private async Task <DialogTurnResult> SummaryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _wifiProduct = new BitrixProductRowModel(); var _wifilicense = new BitrixProductRowModel(); var Basket = await _botAccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel(), cancellationToken); var _current_rate = Basket.currentRate; var _wifilicensesku = stepContext.Values["wifilicense"].ToString(); var _wifimodel = (string)stepContext.Values["wifimodel"]; var _wifiquantity = stepContext.Result.ToString(); var _wifidata = await WebServicesFactory.QueryProductData(_wifimodel, "LIC"); var _price = double.Parse(_wifidata.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD); //get the license for the device var _strippedsku = ProductUtil.generateSKU(_wifimodel); _strippedsku = _strippedsku += Basket.licenseDuration; var _licensedata = await WebServicesFactory.QueryProductData(_wifilicensesku, "HW"); await stepContext.PromptAsync(nameof(NumberPrompt <int>), new PromptOptions { Prompt = MessageFactory.Text($"You ordered {_wifiquantity}x {_wifimodel} at R{_price*_current_rate} each") }); var zar_price = _price * _current_rate; _wifiProduct.PRICE = zar_price; _wifiProduct.PRODUCT_NAME = _wifimodel; _wifiProduct.QUANTITY = _wifiquantity; _wifilicense.PRICE = double.Parse(_licensedata.listJurumaniCloudInventory_Models.Items[0].LIST_PRICE_USD) * _current_rate; _wifilicense.PRODUCT_NAME = _wifilicensesku; _wifilicense.QUANTITY = _wifiquantity; Basket.products.Add(_wifiProduct); Basket.products.Add(_wifilicense); await _botAccessors.QuoteBasket.SetAsync(stepContext.Context, Basket, cancellationToken); return(await stepContext.ReplaceDialogAsync(nameof(AddMoreDevicesDialog), Basket)); }
private async Task <DialogTurnResult> WifiSummaryStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _wifiProduct = new BitrixProductRowModel(); var title = (string)stepContext.Values["wifimodel"]; var value = (string)stepContext.Values["wifimodel"]; var price = float.Parse(stepContext.Result.ToString()); await stepContext.PromptAsync(nameof(NumberPrompt <int>), new PromptOptions { Prompt = MessageFactory.Text($"You ordered {stepContext.Result}x {stepContext.Values["wifimodel"]}") }); var Basket = await _botAccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel(), cancellationToken); Basket.products.Add(_wifiProduct); var convostate = _botAccessors.ConversationState.LoadAsync(stepContext.Context, false, cancellationToken); await _botAccessors.QuoteBasket.SetAsync(stepContext.Context, Basket, cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text(Basket.ToString())); return(await stepContext.ReplaceDialogAsync(nameof(AddMoreDevicesDialog), Basket)); }