Exemplo n.º 1
0
        public async Task GetFeaturesByNoAsync_NotExistionNo_Test()
        {
            // Given
            var features = FakeDataGenerator.CreateDummyFeatures();

            // When
            var allFeatures = await featureService.GetAllFeatures();

            var returnedFeatures = await featureService.GetFeaturesByNoAsync("0", allFeatures);

            // Then
            Assert.NotNull(returnedFeatures);
            Assert.AreEqual(0, returnedFeatures.Count);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method returns every items which match item description or category description or has keywords with same value.
        /// </summary>
        /// <param name="description">Value to look for in item description, category and keywords</param>
        /// <returns>All items by match.</returns>
        public async Task <IEnumerable <PimItem> > GetAllItemsByMatchAsync(string description)
        {
            var pimItems = await _itemRepository.GetAll();

            var keywordsByItemSet = await _keywordService.GetAllKeywordsGroupByItemCodeAsync();

            var filteredByCategory = await FilterByCategory(pimItems, description);

            var filteredByKeywords    = FilterByKeywordsMatch(pimItems, description, keywordsByItemSet);
            var filteredByDescription = FilterByItemDescription(pimItems, description);

            var unitedItems = filteredByDescription
                              .Union(filteredByKeywords)
                              .Union(filteredByDescription);

//            unitedItems.ToList().ForEach(i => _categoryService.GetItemGroupsByNo(i));
            var allFeatures = await _featuresService.GetAllFeatures();

            foreach (var item in unitedItems)
            {
                item.PimFeatures = await _featuresService.GetFeaturesByNoAsync(item.No, allFeatures);
            }

            return(unitedItems);
        }
 public HttpResponseMessage GetAllFeatures()
 {
     try
     {
         var item = Task.Run(async() =>
         {
             return(await featureService.GetAllFeatures());
         });
         var features = item.Result;
         return(CreateHttpResponse <IEnumerable <ISOFeature> >(
                    HttpStatusCode.OK,
                    HttpCustomStatus.Success,
                    features,
                    GetLocalisedString("msgSuccess")));
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         return(CreateHttpResponse <ISOFeature>(
                    HttpStatusCode.ExpectationFailed,
                    HttpCustomStatus.Failure,
                    null,
                    GetLocalisedString("msgWebServiceError")));
     }
 }
Exemplo n.º 4
0
        public async Task <IActionResult> GetAll()
        {
            var features = await _featureService.GetAllFeatures();

            var responses = features.Select(f => (FeatureResponse)f);

            return(Ok(responses));
        }
 public IActionResult GetAllFeatures()
 {
     try
     {
         return(Ok(_FeatureService.GetAllFeatures()));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
        public async Task <IActionResult> GetAll()
        {
            try
            {
                var features = await _featureService.GetAllFeatures();

                var mappedFeatures = _mapper.Map <IEnumerable <FeatureDto> >(features);
                return(Ok(mappedFeatures));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 7
0
        private async Task <DialogTurnResult> InitializeStateStepAsync(
            WaterfallStepContext stepContext,
            CancellationToken cancellationToken)
        {
            var context        = stepContext.Context;
            var onTurnProperty = await _onTurnAccessor.GetAsync(context, () => new OnTurnState());

            if (onTurnProperty.Entities[EntityNames.Item] != null && onTurnProperty.Entities[EntityNames.Item].Count() > 0)
            {
                var firstEntity = (string)onTurnProperty.Entities[EntityNames.Item].First;

                var pimItem = await _itemService.FindItemByNo(firstEntity);

                if (pimItem == null)
                {
                    await context.SendActivityAsync($"{Messages.NotFound} **{firstEntity}**.");

                    return(await stepContext.EndDialogAsync());
                }

                var allFeatures = await _featureService.GetAllFeatures();

                var features = await _featureService.GetFeaturesByNoAsync(pimItem.No, allFeatures);

                var response   = stepContext.Context.Activity.CreateReply();
                var pictureUrl = await _itemService.GetImageUrl(pimItem);

                response.Attachments = new List <Attachment>()
                {
                    CreateAdaptiveCardDetailUsingSdk(pimItem, features, pictureUrl)
                };
                await context.SendActivityAsync(response);
            }

            return(await stepContext.EndDialogAsync());
        }
Exemplo n.º 8
0
        public async Task FilterItemsByFeature_UnitPriceUnderMedian_Test()
        {
            // Given
            var pimItems = await itemService.GetAllItemsByMatchAsync("Chair");

            var featuresToAsk = await itemService.GetAllFeaturesToAsk(pimItems);

            var featureToAsk = featuresToAsk[0];

            // When
            var pimFeatures = await featureService.GetAllFeatures();

            var filteredItems = await itemService.FilterItemsByFeature(pimFeatures, pimItems, featureToAsk,
                                                                       featuresToAsk[0].GetMedianValue().ToString(), (int)FilterInterval.UnderMedian);

            Assert.NotNull(filteredItems);
            Assert.AreEqual(2, filteredItems.Count());

            Assert.AreEqual("1000", filteredItems.First().No);
            Assert.AreEqual(500, filteredItems.First().Unit_Price);

            Assert.AreEqual("1001", filteredItems.ToList()[1].No);
            Assert.AreEqual(700, filteredItems.ToList()[1].Unit_Price);
        }
Exemplo n.º 9
0
 public IEnumerable <Feature> GetFeatues()
 {
     return(_featureService.GetAllFeatures());
 }
Exemplo n.º 10
0
        private async Task <DialogTurnResult> InitializeStateStepAsync(
            WaterfallStepContext stepContext,
            CancellationToken cancellationToken)
        {
            // Initalization of static variables
            askedForFeature  = false;
            questionCounter  = 0;
            questionAkedList = new List <string>();

            var context        = stepContext.Context;
            var onTurnProperty = await _onTurnAccessor.GetAsync(context, () => new OnTurnState());

            if (didYouMean != null || (onTurnProperty.Entities[EntityNames.FindItem] != null &&
                                       onTurnProperty.Entities[EntityNames.FindItem].Count() > 0))
            {
                string firstEntity;
                if (didYouMean == null)
                {
                    firstEntity = (string)onTurnProperty.Entities[EntityNames.FindItem].First;
                }
                else
                {
                    firstEntity = didYouMean;
                }

                // Get all items
                pimItems = await _itemService.GetAllItemsByMatchAsync(firstEntity);

                pimFeatures = await _featureService.GetAllFeatures();

                //                var groupCount = _itemService.GetAllItemsCategory(pimItems).Count();

                if (didYouMean != null)
                {
                    didYouMean = null;
                }

                if (pimItems.Count() == 0)
                {
                    await context.SendActivityAsync($"{Messages.NotFound} **{firstEntity}**.");

                    // Try to find if user doesnt do type error
                    didYouMean = await _itemService.FindSimilarItemsByDescription(firstEntity);

                    return(await stepContext.PromptAsync(
                               DidYouMeanPrompt,
                               new PromptOptions
                    {
                        Prompt = MessageFactory.Text(string.Format(Messages.FindItemDidYouMean, didYouMean)),
                        RetryPrompt = MessageFactory.Text(string.Format(Messages.FindItemDidYouMean, didYouMean) + Messages.CancelPrompt),
                        Choices = ChoiceFactory.ToChoices(new List <string> {
                            Messages.Yes, Messages.No
                        }),
                    },
                               cancellationToken));
                }
                else if (pimItems.Count() == 1)
                {
                    stepContext.ActiveDialog.State["stepIndex"] = ShowItemsDialogIndex;
                    return(await stepContext.ContinueDialogAsync());
                }
                else
                {
                    var prompt = string.Format(Messages.FindItemFound, pimItems.Count(), firstEntity) + Messages.WhatToDoPrompt;

                    return(await stepContext.PromptAsync(
                               ShowAllItemsPrompt,
                               new PromptOptions
                    {
                        Prompt = MessageFactory.Text(prompt),
                        RetryPrompt = MessageFactory.Text(prompt + Messages.CancelPrompt),
                        Choices = ChoiceFactory.ToChoices(new List <string> {
                            Messages.FindItemShowAllItem, Messages.FindItemSpecialize
                        }),
                    },
                               cancellationToken));
                }
            }

            await context.SendActivityAsync(Messages.FindItemForgotItem);

            var categories = await _categoryService.GetAllProductGroupAsync();

            await context.SendActivityAsync(ShowCategoriesDialog.GetPritableGroup(categories));

            return(await stepContext.EndDialogAsync());
        }
Exemplo n.º 11
0
 public PagedResultsDto GetAllFeatures(int page, int pageSize, int tenantId)
 {
     return(_featureService.GetAllFeatures(page, pageSize, tenantId));
 }