public async Task Execute(Input input) { var user = new IdentityUser { UserName = input.UserName, Email = input.Email, PhoneNumber = input.PhoneNumber }; var Email = await AuthenticationRepository.FindByEmail(input.Email); var Username = await AuthenticationRepository.FindByName(input.UserName); var Phone = await AuthenticationRepository.FindByPhoneNumber(input.PhoneNumber); if (Email != null) { OutputHandler.Error("Email Already Exist"); } if (Username != null) { OutputHandler.Error("Username Already Exist"); } if (Phone != null) { OutputHandler.Error("Phone number Already Exist"); } else { var result4 = await AuthenticationRepository.Createuser(user, input.password); OutputHandler.Handle(new Output("Registraction Successful..")); } }
public async Task Execute(Input input) { var r1 = new Regex(@"^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"); var r2 = new Regex(@"^([0-9]{10})$"); if (!string.IsNullOrEmpty(input.UserName) && r1.IsMatch(input.UserName)) { //var result1 = userManager.Users.SingleOrDefault(r => r.Email == model.UserName); //return await logincheck(result1, model.password); var result1 = await AuthenticationRepository.FindByEmail(input.UserName); if (result1 == null) { OutputHandler.Error("Email not Found"); } else { var output = await logincheck(result1, input.Password); OutputHandler.Handle(new Output(output.ToString())); } } else if (!string.IsNullOrEmpty(input.UserName) && r2.IsMatch(input.UserName)) { //var result2 = userManager.Users.SingleOrDefault(r => r.PhoneNumber == model.UserName); //return await logincheck(result2, model.password); var result2 = await AuthenticationRepository.FindByPhoneNumber(input.UserName); if (result2 == null) { OutputHandler.Error("PhoneNumber Not Found"); } else { var output1 = await logincheck(result2, input.Password); OutputHandler.Handle(new Output(output1.ToString())); } } else { var result3 = await AuthenticationRepository.FindByName(input.UserName); if (result3 == null) { OutputHandler.Error("UserName not Found"); } else { var output2 = await logincheck(result3, input.Password); OutputHandler.Handle(new Output(output2.ToString())); } } }