public async Task <IActionResult> Register([FromBody] UserModelViewModel model) { if (ModelState.IsValid) { var user = new AppUser { UserName = model.UserName, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); // Send an email with this link var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Link("confirmEmail", new { userId = user.Id, code = code }); await _emailSender.SendEmailAsync(model.UserName, "Confirmação de cadastro", $"Por favor confirme seu cadastro clicando <a href='{callbackUrl}'>Aqui</a>"); _logger.LogInformation(3, "User created a new account with password."); var url = Url.Link("token", null); return(Ok(new { message = $"por favor confirme o e-mail enviado para { model.UserName }" })); } AddErrors(result); } return(BadRequest(ModelState)); }
public ActionResult EditUser(int UserId) { UserModelViewModel user; using (UserContext db = new UserContext()) { user = new UserModelViewModel(db.UserModels.Find(UserId)); } return(PartialView(user)); }
public bool SaveUser(UserModelViewModel client) { UserModel model = new UserModel { Id = client.Id, Name = client.Name, Name_DativeCase = client.Name_DativeCase, Surname = client.Surname, Surname_DativeCase = client.Surname_DativeCase, Patronymic = client.Patronymic, Patronymic_DativeCase = client.Patronymic_DativeCase, CompanyId = client.CompanyId, Position = client.Position, Education = client.Education }; return(SendDbUtility.UpdateUser(model)); }
public ActionResult UserToDb(UserModelViewModel client) { UserModel model = new UserModel { Name = client.Name, Name_DativeCase = client.Name_DativeCase, Surname = client.Surname, Surname_DativeCase = client.Surname_DativeCase, Patronymic = client.Patronymic, Patronymic_DativeCase = client.Patronymic_DativeCase, CompanyId = client.CompanyId, Position = client.Position, Education = client.Education }; SendDbUtility.SendUserToDb(model); return(RedirectToAction("Home", "Pattern")); }
public ActionResult EditUser(UserModelViewModel model) { using (UserContext db = new UserContext()) { var user = db.UserModels.Find(model.Id); user.CompanyId = model.CompanyId; user.Name = model.Name; user.Name_DativeCase = model.Name_DativeCase; user.Surname = model.Surname; user.Surname_DativeCase = model.Surname_DativeCase; user.Patronymic = model.Patronymic; user.Patronymic_DativeCase = model.Patronymic_DativeCase; user.CompanyId = model.CompanyId; user.Position = model.Position; user.Education = model.Education; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("GetTable")); }