public async Task <IActionResult> ChangePassword(ChangePasswordViewModel model) { var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var changePasswordResult = await _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); if (!changePasswordResult.Succeeded) { AddErrors(changePasswordResult); return(RedirectToAction(nameof(Index))); } await _signInManager.SignInAsync(user, isPersistent : false); StatusMessage = "Sua senha foi trocada com sucesso."; SweetAlertBuilder alert = new SweetAlertBuilder("Senha alterada!", StatusMessage, MessageType.Success); ScriptManager.SetStartupScript(TempData, alert.BuildScript()); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> ForgotPassword(ForgotPasswordViewModel model) { SweetAlertBuilder alert = new SweetAlertBuilder("Reset de senha", "Um e-mail de reset de senha foi enviado para você no e-mail informado.", MessageType.Info); if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist or is not confirmed ScriptManager.SetStartupScript(TempData, alert.BuildScript()); return(RedirectToAction(nameof(Login))); } // For more information on how to enable account confirmation and password reset please // visit https://go.microsoft.com/fwlink/?LinkID=532713 var code = await _userManager.GeneratePasswordResetTokenAsync(user); var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme); await _emailSender.SendEmailAsync(model.Email, "Reset Password", $"Please reset your password by clicking here: {callbackUrl}"); ScriptManager.SetStartupScript(TempData, alert.BuildScript()); return(RedirectToAction(nameof(Login))); } // If we got this far, something failed, redisplay form return(RedirectToAction(nameof(Login))); }
private void BuildSweetAlert(string title, string message, Constants.AlertStatus status) { var alert = new SweetAlertBuilder { HexaBackgroundColor = "#fff", Title = title, Message = message, AlertIcons = status }; alert.BuildSweetAlert(this); }
private void BuildSweetAlert(string hexaBgColor, AlertStatus alertStatus, string title, string message) { SweetAlertBuilder sweetAlertBuilder = new SweetAlertBuilder { HexaBackgroundColor = hexaBgColor, AlertIcons = alertStatus, Title = title, Message = message, }; sweetAlertBuilder.BuildSweetAlert(this); }
private void BuildSweetAlert(string hexbgColor, string title, string message, Constants.AlertStatus alertStatus) { var sweetAlert = new SweetAlertBuilder { HexaBackgroundColor = hexbgColor, Title = title, Message = message, AlertIcons = alertStatus, ShowConfirmationDialog = true, }; sweetAlert.BuildSweetAlert(this); }
private void BuildSweetAlert(string title, string message, Constants.AlertStatus alertStatus) { var sweetAlert = new SweetAlertBuilder { HexaBackgroundColor = "#fff", Title = title, Message = message, AlertIcons = alertStatus, AlertPositions = Constants.AlertPositions.CENTER }; sweetAlert.BuildSweetAlert(this); }
public override void OnException(ExceptionContext context) { var controllerName = context.RouteData.Values["controller"]; var actionName = context.RouteData.Values["action"]; var factory = AppDependencyResolver.Current.GetService <ITempDataDictionaryFactory>(); var alert = new SweetAlertBuilder("Um erro ocorreu! :(", context.Exception.Message, MessageType.Danger); ScriptManager.SetStartupScript(factory.GetTempData(context.HttpContext), alert.BuildScript()); context.ExceptionHandled = true; // mark exception as handled context.Result = new RedirectResult($"/{controllerName}/{actionName}"); }
private void BuildSweetAlert(string hexBackgroundColor, string title, string message, Constants.AlertStatus alertStatus) { SweetAlertBuilder sweetAlertBuilder = new SweetAlertBuilder { HexaBackgroundColor = hexBackgroundColor, Title = title, Message = message, AlertIcons = alertStatus, ShowCloseButton = true, AlertPositions = Constants.AlertPositions.TOP_START }; sweetAlertBuilder.BuildSweetAlert(this); }
public async Task <IActionResult> Index(UserViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } user.Nome = model.Nome; user.Sobrenome = model.Sobrenome; user.PhoneNumber = model.PhoneNumber; await _userManager.UpdateAsync(user); var email = user.Email; if (model.Email != email) { var setEmailResult = await _userManager.SetEmailAsync(user, model.Email); if (!setEmailResult.Succeeded) { throw new ApplicationException($"Unexpected error occurred setting email for user with ID '{user.Id}'."); } } var phoneNumber = user.PhoneNumber; if (model.PhoneNumber != phoneNumber) { var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, model.PhoneNumber); if (!setPhoneResult.Succeeded) { throw new ApplicationException($"Unexpected error occurred setting phone number for user with ID '{user.Id}'."); } } SweetAlertBuilder builder = new SweetAlertBuilder("Perfil atualizado", "Seu perfil foi atualizado com sucesso!", MessageType.Success); ScriptManager.SetStartupScript(TempData, builder.BuildScript()); return(RedirectToAction(nameof(Index))); }
protected void FindDate_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(Date.Text.ToString())) { SweetAlertBuilder sweetAlert = new SweetAlertBuilder { HexaBackgroundColor = "#fff", Title = "Error Date", Message = "Invalid Date Pls Pick a Date!", AlertIcons = Constants.AlertStatus.error }; sweetAlert.BuildSweetAlert(this); return; } DateTime date = DateTime.Parse(Date.Text.ToString()); LoadTotalSalesAtGivenDate(date); UpdatePanel1.Update(); }
protected void RegisterSweetAlertMessage(string messageTitle, string message, MessageType type) { SweetAlertBuilder alert = new SweetAlertBuilder(messageTitle, message, type); ScriptManager.SetStartupScript(TempData, alert.BuildScript()); }