public async Task <SearchQueryResult <MedicinalPackageResult> > Handle(SearchMedicinalPackageQuery query, CancellationToken token)
        {
            var result = await _ampService.SearchMedicinalPackage(new SearchAmpRequest
            {
                Count               = query.Count,
                StartIndex          = query.StartIndex,
                DeliveryEnvironment = query.DeliveryEnvironment.Code,
                IsCommercialised    = query.IsCommercialised,
                ProductName         = query.SearchText
            }, token);

            return(new SearchQueryResult <MedicinalPackageResult>
            {
                Count = result.Count,
                StartIndex = result.StartIndex,
                Content = result.Content.Select(_ => new MedicinalPackageResult
                {
                    LeafletUrlLst = Convert(_.LeafletUrlLst),
                    SpcUrlLst = Convert(_.SpcUrlLst),
                    CrmUrlLst = Convert(_.CrmUrlLst),
                    Code = _.DeliveryMethods.First().Code,
                    Price = _.DeliveryMethods.First().Price,
                    Reimbursable = _.DeliveryMethods.First().Reimbursable,
                    Names = Convert(_.PrescriptionNames)
                }).ToList()
            });
        }
        private static SearchMedicinalPackageQuery BuildRequest(IEnumerable <KeyValuePair <string, object> > query)
        {
            var    result = new SearchMedicinalPackageQuery();
            int    startIndex;
            int    count;
            string searchText;
            bool   isCommercialised;
            int    deliveryEnvironmentInt;

            if (query.TryGet("start_index", out startIndex))
            {
                result.StartIndex = startIndex;
            }

            if (query.TryGet("count", out count))
            {
                result.Count = count;
            }

            if (query.TryGet("search_text", out searchText))
            {
                result.SearchText = searchText;
            }

            if (query.TryGet("is_commercialised", out isCommercialised))
            {
                result.IsCommercialised = isCommercialised;
            }

            if (query.TryGet("delivery_environment", out deliveryEnvironmentInt))
            {
                if (Enumeration.TryParse(deliveryEnvironmentInt, out DeliveryEnvironments deliveryEnv))
                {
                    result.DeliveryEnvironment = deliveryEnv;
                }
            }

            return(result);
        }
Exemplo n.º 3
0
 public Task <SearchQueryResult <MedicinalPackageResult> > Search(SearchMedicinalPackageQuery query)
 {
     return(_mediator.Send(query));
 }