Esempio n. 1
0
        private async Task <DialogTurnResult> NameStepAsync(WaterfallStepContext stepContext, CancellationToken cancellation)
        {
            var customerProfile = (CustomerModel)stepContext.Values[customerInfo];
            var customerDetails = CustomerUtil.getCustomerByPhoneNumber(stepContext.Result.ToString());

            if (customerDetails.Count > 0)
            {
                customerProfile = customerDetails[0];
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Hi {customerDetails[0].NAME} {customerDetails[0].LAST_NAME}  company id is {customerDetails[0].COMPANY_ID}"));

                customerProfile.NAME = customerDetails[0].NAME;

                var cacheCustomerInfo = await _botaccessors.UserProfile.GetAsync(stepContext.Context, () => new CustomerModel());

                cacheCustomerInfo.NAME       = customerDetails[0].NAME;
                cacheCustomerInfo.LAST_NAME  = customerDetails[0].LAST_NAME;
                cacheCustomerInfo.PHONE      = customerDetails[0].PHONE;
                cacheCustomerInfo.COMPANY_ID = customerDetails[0].COMPANY_ID;
                cacheCustomerInfo.EMAIL      = customerDetails[0].EMAIL;

                await _botaccessors.UserProfile.SetAsync(stepContext.Context, cacheCustomerInfo, cancellation);

                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"saved company id {cacheCustomerInfo.COMPANY_ID}"));

                return(await stepContext.ReplaceDialogAsync(nameof(MerakiDeviceBoMDialog)));
            }
            else
            {
                var phonegeneric = new Generics();
                phonegeneric.VALUE = stepContext.Result.ToString();
                List <Generics> PHONE = new List <Generics>()
                {
                    phonegeneric
                };

                var custdata = (CustomerModel)stepContext.Values[customerInfo];
                custdata.PHONE = PHONE;
                var cacheCustomerProfile = await _botaccessors.UserProfile.GetAsync(stepContext.Context, () => new CustomerModel(), cancellation);

                cacheCustomerProfile = custdata;
                await _botaccessors.UserProfile.SetAsync(stepContext.Context, cacheCustomerProfile, cancellation);

                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please enter your Name") }, cancellation));
            }
        }
Esempio n. 2
0
        private async Task <DialogTurnResult> NameStepAsync(WaterfallStepContext stepContext, CancellationToken cancellation)
        {
            var customerProfile = (CustomerModel)stepContext.Values["customerinfo"];
            var customerDetails = CustomerUtil.getCustomerByPhoneNumber(stepContext.Result.ToString());

            if (customerDetails.Count > 0)
            {
                customerProfile = customerDetails[0];
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Hi {customerDetails[0].NAME} {customerDetails[0].LAST_NAME}"));

                customerProfile.NAME = customerDetails[0].NAME;

                var Basket = await _botAccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel());

                Basket.customer = customerProfile;

                await _botAccessors.QuoteBasket.SetAsync(stepContext.Context, Basket, cancellation);

                return(await stepContext.ReplaceDialogAsync("DeviceBOMDialog"));
            }
            else
            {
                var phonegeneric = new Generics();
                phonegeneric.VALUE = stepContext.Result.ToString();
                List <Generics> PHONE = new List <Generics>()
                {
                    phonegeneric
                };

                var custdata = (CustomerModel)stepContext.Values["customerinfo"];
                custdata.PHONE = PHONE;
                //var cacheCustomerProfile = await _botAccessors.QuoteBasket.GetAsync(stepContext.Context, () => new QuoteBasketModel(), cancellation);
                //cacheCustomerProfile.customer = custdata;
                //await _botAccessors.QuoteBasket.SetAsync(stepContext.Context, cacheCustomerProfile, cancellation);
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please enter your Name") }, cancellation));
            }
        }