public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { var user = new StUser { UserId = Input.UserId, FirstName = Input.FirstName, LastName = Input.LastName, City = Input.City }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
public static StUser SpUserMasterGetDataStructById(string UserId) { // get a configured DbCommand object DbCommand comm = DataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "SpUserMasterGetDataStructById"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@UserId"; param.Value = UserId; param.DbType = DbType.Int32; comm.Parameters.Add(param); //execute procedure and store data in table DataTable table = DataAccess.ExecuteSelectCommand(comm); //create object of structure StUser details = new StUser(); //check there is row in table or not if (table.Rows.Count > 0) { //create data reader DataRow dr = table.Rows[0]; //store individually each field into object details.userid = Convert.ToInt32(dr["userid"]); details.roleid = Convert.ToInt32(dr["roleid"]); details.username = dr["username"].ToString(); details.password = dr["password"].ToString(); details.employeeid = Convert.ToInt32(dr["employeeid"]); } //return object with data return(details); }