public async Task <IActionResult> Register([FromForm] RegisterRequest request) { if (ModelState.IsValid) { var result = await _userAPIClient.Register(request); if (result.IsSuccessed == false) { TempData["message"] = result.Message; ModelState.AddModelError("", result.Message); ViewBag.ErrorServerSide = true; return(View()); } var sent = await SendMailAsync(request.Email); if (sent == true) { ViewBag.Email = request.Email; ViewBag.UserId = result.ResultObject.UserId; ViewBag.Token = result.ResultObject.Token; return(View("ConfirmEmail")); } ModelState.AddModelError(string.Empty, "Send Verifition code Faild"); return(RedirectToAction("Index", "Login")); } else { return(View()); } }
public async Task <IActionResult> Register([FromForm] RegisterRequest request) { if (ModelState.IsValid) { var result = await _userAPIClient.Register(request); if (result.IsSuccessed == true) { TempData["result"] = "Register Success"; TempData["IsSuccess"] = true; } else { TempData["result"] = result.Message; TempData["IsSuccess"] = false; } return(RedirectToAction("Index", "User")); } else { return(BadRequest(ModelState)); } }