public virtual async Task <IHttpActionResult> IsUserExist(string email) { var getCustomerByEmailParam = new GetCustomerByEmailParam { CultureInfo = ComposerContext.CultureInfo, Scope = ComposerContext.Scope, Email = email }; var isUserExistViewModel = await MembershipViewService.GetIsUserExistViewModelAsync(getCustomerByEmailParam); return(Ok(isUserExistViewModel)); }
/// <summary> /// Search Customers by email /// </summary> /// <param name="getCustomerByEmailParam">The Repository call params <see cref="GetCustomerByEmailParam"/></param> /// <returns> /// The Customer matching the requested Email, or null /// </returns> public virtual Task <CustomerQueryResult> GetCustomerByEmailAsync(GetCustomerByEmailParam getCustomerByEmailParam) { if (getCustomerByEmailParam == null) { throw new ArgumentNullException(nameof(getCustomerByEmailParam)); } if (getCustomerByEmailParam.CultureInfo == null) { throw new ArgumentException(nameof(getCustomerByEmailParam.CultureInfo)); } if (string.IsNullOrWhiteSpace(getCustomerByEmailParam.Scope)) { throw new ArgumentException(nameof(getCustomerByEmailParam.Scope)); } if (string.IsNullOrWhiteSpace(getCustomerByEmailParam.Email)) { throw new ArgumentException(nameof(getCustomerByEmailParam.Email)); } var cacheKey = new CacheKey(CacheConfigurationCategoryNames.Customer + "Search") { Scope = getCustomerByEmailParam.Scope, CultureInfo = getCustomerByEmailParam.CultureInfo, }; cacheKey.AppendKeyParts(getCustomerByEmailParam.Email); var request = new FindCustomersRequest { SearchTerms = getCustomerByEmailParam.Email, FilteringScopes = getCustomerByEmailParam.Scope, ScopeId = getCustomerByEmailParam.Scope, Query = new Query { IncludeTotalCount = true, Sortings = new List <QuerySorting> { new QuerySorting { PropertyName = "AccountStatus", Direction = SortDirection.Ascending }, new QuerySorting { PropertyName = "LastActivityDate", Direction = SortDirection.Descending } } } }; return(CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request))); }
/// <summary> /// Return true if the user exist /// </summary> /// <param name="param">Builder params <see cref="GetCustomerByEmailParam"/></param> /// <returns> /// The view model is user exist /// </returns> public virtual async Task <IsUserExistViewModel> GetIsUserExistViewModelAsync(GetCustomerByEmailParam getCustomerByEmailParam) { var customerQueryResult = await CustomerRepository.GetCustomerByEmailAsync(getCustomerByEmailParam).ConfigureAwait(false); return(new IsUserExistViewModel { IsExist = customerQueryResult.Results.Any(customer => customer.Email == getCustomerByEmailParam.Email) }); }