public bool RegisterStore(RegisterStoreDtoCommand command) { string email = command.Email.ToLower(); string storeName = command.StoreName; string eWalletAccNo = command.EWalletAccNo; string otp = Generator.GenerateRandomString(20); bool isCreateStore = _storeRepository.CreateStore(email, storeName, eWalletAccNo, otp); if (!isCreateStore) { return(false); } int storeId = _storeRepository.GetStoreIdByEmail(email); if (storeId == default) { return(false); } bool isCreateToken = _tokenRepository.CreateTokenByStoreId(storeId); if (!isCreateStore) { return(false); } string value = SentEmailValue + $"SetPassword?otp={otp}&&email={email}"; SendEmail(email, value); return(true); }
public IActionResult CallAPIRegisStoer(string email, string storeName, string eWalletAccNo) { email = email.ToLower(); bool isEmail = _authService.ChechEmail(email); if (isEmail) { return(RedirectToAction("Error", "Register", new { message = "E-Mail นี้ถูกใช้งานแล้ว" })); } bool isStroe = _authService.CheckStore(storeName); if (isStroe) { return(RedirectToAction("Error", "Register", new { message = "ชื่อร้านนี้ถูกใช้งานแล้ว" })); } if (!CheckEWalletAccNo(eWalletAccNo)) { return(RedirectToAction("Error", "Register", new { message = "Account Number ของ Application EnixerWallet ไม่มีอยู่ในระบบ" })); } RegisterStoreDtoCommand command = new RegisterStoreDtoCommand() { Email = email, StoreName = storeName, EWalletAccNo = eWalletAccNo }; bool isRegis = _authService.RegisterStore(command); if (isRegis) { return(RedirectToAction("SuccessPage", "Register", new { message = "ลงทะเบียนสำเร็จแล้ว\nโปรดทำการตั้งรหัสผ่านจาก Link ที่ส่งให้ถ้า E-Mail" })); } else { return(RedirectToAction("Error", "Register", new { message = "ไม่สามารถลงทะเบียนได้" })); } }