Exemplo n.º 1
0
        private bool IsMemberExists(CustomerImport client)
        {
            CustomerImport customerImport = null;

            client.HandleCustomer();

            if (client.Email.IsValidEmail())
            {
                customerImport = customerImportRepository.GetByEmail(client.Email).FirstOrDefault();
            }

            if ((customerImport.IsNull() || customerImport.AccountCode.IsEmpty()) && client.DisplayDocument.IsValidCPF())
            {
                customerImport = customerImportRepository.GetByCPF(client.DisplayDocument).FirstOrDefault();
            }

            if ((customerImport.IsNull() || customerImport.AccountCode.IsEmpty()) && client.DisplayDocument.IsValidCNPJ())
            {
                customerImport = customerImportRepository.GetByCNPJ(client.DisplayDocument).FirstOrDefault();
            }

            if (!customerImport.IsNull() && !customerImport.AccountCode.IsEmpty())
            {
                return(true);
            }

            var account = new Account()
            {
                Email    = client.Email,
                Document = client.DisplayDocument,
                Login    = client.Email
            };

            return(accountRepository.IsMemberExists(account));;
        }
Exemplo n.º 2
0
        public CustomerImport Get(string username, Guid storeCode)
        {
            CustomerImport customerImport = null;

            if (username.IsValidEmail())
            {
                customerImport = customerImportRepository.GetByEmail(username, storeCode);
            }
            else if (username.IsValidCPF())
            {
                customerImport = customerImportRepository.GetByCPF(username, storeCode);
            }
            else if (username.IsValidCNPJ())
            {
                customerImport = customerImportRepository.GetByCNPJ(username, storeCode);
            }

            return(customerImport);
        }