public async Task <bool> IsAuthorizedAsync(string identifier)
        {
            var criteria = new MembersSearchCriteria
            {
                SearchPhrase = $"botusername:{identifier}"
            };

            var result = await _customerModuleApi.SearchContactsAsync(criteria);

            var vcCustomer = result.Results.FirstOrDefault();

            if (vcCustomer != null)
            {
                _customer.Id      = vcCustomer.Id;
                _customer.StoreId = vcCustomer.SecurityAccounts.FirstOrDefault()?.StoreId;
                _customer.Name    = vcCustomer.Name;

                if (!string.IsNullOrEmpty(_customer.StoreId))
                {
                    var store = await _storeModule.GetStoreByIdAsync(_customer.StoreId);

                    _customer.Currency = store.DefaultCurrency;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public async Task <IPagedList <Contact> > SearchOrganizationContactsAsync(OrganizationContactsSearchCriteria criteria)
        {
            var criteriaDto = new customerDto.MembersSearchCriteria
            {
                MemberId     = criteria.OrganizationId,
                Skip         = (criteria.PageNumber - 1) * criteria.PageSize,
                Take         = criteria.PageSize,
                Sort         = criteria.Sort,
                SearchPhrase = criteria.SearchPhrase,
                ObjectType   = "Member"
            };
            var searchResult = await _customerApi.SearchContactsAsync(criteriaDto);

            var contacts = searchResult.Results.Select(x => x.ToContact()).ToList();

            return(new StaticPagedList <Contact>(contacts, criteria.PageNumber, criteria.PageSize, searchResult.TotalCount ?? 0));
        }