public async Task <bool> SignUp(CustomerAccount customer) { string emailRegex = "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?!-)(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$"; string phoneRegex = "^\\d{8,15}$"; if (customer == null) { return(false); } if (customer.CustomerFirstName.Length <= 0 || customer.CustomerLastName.Length <= 0 || customer.CustomerEmail.Length <= 0 || (customer.CustomerPhoneNumber.Length < 8 && customer.CustomerPhoneNumber.Length > 15) || customer.CustomerIdentification.Length < 8 || customer.CustomerAddress.Length < 3) { return(false); } if (!Regex.IsMatch(customer.CustomerEmail, emailRegex)) { return(false); } if (!Regex.IsMatch(customer.CustomerPhoneNumber, phoneRegex)) { return(false); } bool sendMail = false; for (int i = 0; i < 5; i++) { customer.CustomerNo = AppUtils.CreateRandomString(null, 11); bool success = await _repository.InsertCustomer(customer); if (success) { string mailContent = AppUtils.CreateEmailActiveAccount(customer.CustomerFirstName + " " + customer.CustomerLastName, customer.CustomerNo, Regex.Replace(AppUtils.HashString(customer.CustomerNo), "\\W+", "")); sendMail = await _mailService.SendEmail(customer.CustomerEmail, "Welcome to ARS Airways", mailContent); break; } } if (sendMail) { return(true); } else { await _repository.DeleteCustomer(customer.CustomerNo); } return(false); }