public async Task <CustomerListResponse> GetCustomersAsync([FromBody] CustomerListRequest model) { if (!string.IsNullOrEmpty(model.SearchValue)) { CustomerProfileResponse response = null; if (model.SearchValue.IsValidEmail()) { response = await _customerProfileClient.CustomerProfiles.GetByEmailAsync( new GetByEmailRequestModel { Email = model.SearchValue, IncludeNotVerified = true }); } else if (Guid.TryParse(model.SearchValue, out Guid customerId)) { response = await _customerProfileClient.CustomerProfiles.GetByCustomerIdAsync(customerId.ToString(), true); } var customers = response?.Profile == null ? new List <CustomerModel>() : new List <CustomerModel> { _mapper.Map <CustomerModel>(response.Profile) }; if (customers.Any()) { await SetCustomersStatuses(customers); } return(new CustomerListResponse { Customers = customers, PagedResponse = new PagedResponseModel(1, response?.Profile == null ? 0 : 1) }); } var result = await _customerProfileClient.CustomerProfiles.GetCustomersPaginatedAsync( new PaginationModel { CurrentPage = model.CurrentPage, PageSize = model.PageSize }, true); var resultCustomers = _mapper.Map <List <CustomerModel> >(result.Customers); foreach (var batch in resultCustomers.Batch(BatchCustomersCount)) { await SetCustomersStatuses(batch.ToList()); } return(new CustomerListResponse { Customers = resultCustomers, PagedResponse = new PagedResponseModel(result.CurrentPage, result.TotalCount) }); }
public ResultResponse <CustomerProfileResponse> getProfileCustomer(BDHomeFoodContext _context, int costumerid) { try { ResultResponse <CustomerProfileResponse> response = new ResultResponse <CustomerProfileResponse>(); var customer = _context.Customer.Any(c => c.CustomerId == costumerid); if (customer) { var result = _context.Customer.FirstOrDefault(c => c.CustomerId == costumerid); CustomerProfileResponse customerProfileResponse = new CustomerProfileResponse { CustomerId = result.CustomerId, Names = result.Names, LastNames = result.LastNames, DocumentoIdentity = result.DocumentoIdentity, Email = result.Email, Phone = result.Phone, Birthdate = result.Birthdate, Username = result.Username, State = result.State, CreateDate = result.CreateDate, UpdateDate = result.UpdateDate }; response.Data = customerProfileResponse; response.Error = false; response.Message = "Datos encontrados"; } else { response.Data = null; response.Error = true; response.Message = "No se encontraron datos"; } return(response); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task Save_Encrypted_Sensitive_Data_Of_Referral_Lead_While_Creating() { // arrange var profileFixture = new CustomerProfileResponse() { Profile = new CustomerProfile.Client.Models.Responses.CustomerProfile() { Email = "*****@*****.**" }, ErrorCode = CustomerProfileErrorCodes.None }; _customerProfileClientMock.Setup(c => c.CustomerProfiles.GetByCustomerIdAsync(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>())) .ReturnsAsync(profileFixture); var emailHash = _referralLeadCreateInfo.Email.ToSha256Hash(); var phoneNumberE164 = PhoneUtils.GetE164FormattedNumber(_referralLeadCreateInfo.PhoneNumber, _countryPhoneCode.IsoCode); var phoneNumberHash = phoneNumberE164.ToSha256Hash(); // act await _service.CreateReferralLeadAsync(_referralLeadCreateInfo); // assert _referralLeadRepositoryMock.Verify(o => o.CreateAsync( It.Is <ReferralLeadEncrypted>(referralLeadEncrypted => referralLeadEncrypted.EmailHash == emailHash && referralLeadEncrypted.PhoneNumberHash == phoneNumberHash && referralLeadEncrypted.PhoneCountryCodeId == _countryPhoneCode.Id && referralLeadEncrypted.AgentId == _referralLeadCreateInfo.AgentId && referralLeadEncrypted.AgentSalesforceId == _agent.SalesforceId && referralLeadEncrypted.State == ReferralLeadState.Pending)), Times.Once); }
public async Task Create_Referral_Lead_Profile_While_Creating() { // arrange var phoneNumberE164 = PhoneUtils.GetE164FormattedNumber(_referralLeadCreateInfo.PhoneNumber, _countryPhoneCode.IsoCode); var profileFixture = new CustomerProfileResponse { Profile = new CustomerProfile.Client.Models.Responses.CustomerProfile { Email = "*****@*****.**" }, ErrorCode = CustomerProfileErrorCodes.None }; _customerProfileClientMock.Setup(c => c.CustomerProfiles.GetByCustomerIdAsync(It.IsAny <string>(), false, false)) .ReturnsAsync(profileFixture); // act await _service.CreateReferralLeadAsync(_referralLeadCreateInfo); // assert _customerProfileClientMock.Verify(o => o.ReferralLeadProfiles.AddAsync( It.Is <ReferralLeadProfileRequest>(request => request.ReferralLeadId == _referralId && request.FirstName == _referralLeadCreateInfo.FirstName && request.LastName == _referralLeadCreateInfo.LastName && request.Email == _referralLeadCreateInfo.Email && request.PhoneNumber == phoneNumberE164 && request.Note == _referralLeadCreateInfo.Note )), Times.Once); }
public NotificationPublisherServiceTestsFixture() { EmailMessageEventMock = new Mock <IRabbitPublisher <EmailMessageEvent> >(MockBehavior.Strict); SmsEventMock = new Mock <IRabbitPublisher <SmsEvent> >(MockBehavior.Strict); PushNotificationPublisher = new Mock <IRabbitPublisher <PushNotificationEvent> >(MockBehavior.Strict); CustomerProfileMock = new Mock <ICustomerProfileClient>(MockBehavior.Strict); UrlShortenerClientMock = new Mock <IUrlShortenerClient>(MockBehavior.Strict); EmailLinkFormat = "Link-{0}"; Service = new NotificationPublisherService( EmailMessageEventMock.Object, SmsEventMock.Object, PushNotificationPublisher.Object, CustomerProfileMock.Object, UrlShortenerClientMock.Object, EmailLinkFormat, string.Empty, string.Empty, EmailLinkFormat, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, true ); FirstName = "firstn"; LastName = "lastn"; PhoneNumber = "123123123"; CountryCode = "358"; Email = "email"; IsEmailVerified = true; CustomerProfileResponse = new CustomerProfileResponse { ErrorCode = CustomerProfileErrorCodes.None, Profile = new CustomerProfile.Client.Models.Responses.CustomerProfile { CustomerId = CustomerId.ToString(), Email = Email, FirstName = FirstName, LastName = LastName, IsEmailVerified = IsEmailVerified, PhoneNumber = PhoneNumber, Registered = DateTime.UtcNow } }; ReferralHotelProfileResponse = new ReferralHotelProfileResponse { ErrorCode = ReferralHotelProfileErrorCodes.None, Data = new ReferralHotelProfile { ReferralHotelId = Guid.Empty, Email = Email } }; ShortenUrlResponseModel = new ShortenUrlResponseModel { ShortenedUrl = EmailLinkFormat }; SetupCalls(); }