private bool Save() { var result = false; var account = HccApp.MembershipServices.Customers.Find(CustomerId); if (account == null) { account = new CustomerAccount(); } var oldEmailAddress = account.Email.Trim().ToLower(); var newEmailAddress = EmailField.Text.Trim().ToLower(); var emailChanged = oldEmailAddress != newEmailAddress; var isNewUser = string.IsNullOrEmpty(CustomerId); account.Notes = CommentField.Text.Trim(); account.FirstName = FirstNameField.Text.Trim(); account.LastName = LastNameField.Text.Trim(); account.TaxExempt = chkTaxExempt.Checked; account.TaxExemptionNumber = txtTaxExemptionNumber.Text.Trim(); account.PricingGroupId = PricingGroupDropDownList.SelectedValue; var usrStatus = CreateUserStatus.None; if (isNewUser) // Create NEW customer account { if (!MembershipUtils.CheckPasswordComplexity(Membership.Provider, PasswordField.Text.Trim())) { ucMessageBox.ShowError(string.Format(Localization.GetString("revPassword.ErrorMessage"), WebAppSettings.PasswordMinimumLength)); return(false); } account.Email = EmailField.Text.Trim(); account.Username = UsernameField.Text; result = HccApp.MembershipServices.CreateCustomer(account, out usrStatus, PasswordField.Text.Trim()); } else // Update EXIST customer account { result = HccApp.MembershipServices.UpdateCustomer(account, out usrStatus); // Send email changed notification if (result && emailChanged) { if (HccApp.MembershipServices.UpdateCustomerEmail(account, newEmailAddress)) { HccApp.CurrentRequestContext.IntegrationEvents.CustomerAccountEmailChanged(oldEmailAddress, account.Email); } } } if (!result) { HandleCreationError(usrStatus); } return(result); }
public ActionResult GestioneRuoli(int id) { GestioneRuoliModel model = new GestioneRuoliModel(); model.UtenteID = id; MembershipService service = new MembershipService(); Utente utente = service.RecuperaUtente(id); Utente utenteCorrente = MembershipUtils.RecuperaUtenteCorrente(); List <RuoloUtente> ruoli = new List <RuoloUtente>(); ruoli = service.RecuperaListaRuoliUtente(); if (utente.ID == utenteCorrente.ID) { model.UtenteCorrente = true; } else { model.UtenteCorrente = false; } model.Utente = utente; model.RuoliUtente.AddRange(ruoli); return(View(model)); }
// GET: /Home/ public ActionResult Index() { HomeIndexModel model = new HomeIndexModel(); Utente utente = MembershipUtils.RecuperaUtenteCorrente(); model.Utente = utente; return(View(model)); }
public ActionResult ModificaUtente(int id) { ActionResult result = null; ModificaUtenteModel model = new ModificaUtenteModel(); MembershipService service = new MembershipService(); Utente utente = service.RecuperaUtente(id); Utente utenteCorrente = MembershipUtils.RecuperaUtenteCorrente(); if (utenteCorrente.ID == utente.ID) { model.UtenteCorrente = true; } else { model.UtenteCorrente = false; } //UtenteRepository.Instance.RecuperaUtenteDaEmail(utente.Email); if (utente != null) { model.Id = id; model.Nome = utente.Nome; model.NomeUtente = utente.NomeUtente; model.DataUltimoLogin = utente.DataUltimoLogin; model.Cognome = utente.Cognome; model.Email = utente.Email; model.Abilitato = utente.Abilitato; model.DataUltimoCambioPassword = utente.DataUltimoCambioPassword; result = View(model); } else { result = HttpNotFound(); } return(result); }
public ActionResult SetFirstPassword() { var email = Request.Form["email"] ?? string.Empty; var password = Request.Form["password"] ?? string.Empty; var orderbvin = Request.Form["orderbvin"] ?? string.Empty; var resp = new SimpleResponse { Success = true }; var order = HccApp.OrderServices.Orders.FindForCurrentStore(orderbvin); if (order == null) { resp.Success = false; resp.Messages += "Order id was invalid for password reset. "; } else { if (order.CustomProperties.Where(y => (y.DeveloperId == "hcc") && (y.Key == "allowpasswordreset") && (y.Value == "1")).Count() < 1) { resp.Success = false; resp.Messages += "This order does not allow password reset anymore. Please use the 'Forgot Password' link when signing in. "; } } if (!MembershipUtils.CheckPasswordComplexity(Membership.Provider, password.Trim())) { resp.Success = false; resp.Messages += "Password must be at least " + WebAppSettings.PasswordMinimumLength + " characters long. "; } if (resp.Success) { try { var userId = Convert.ToInt32(order.UserID); DnnUserController.Instance.ResetPassword(userId, password, ""); // Turn off reset key so that this can only happen once. var prop = order.CustomProperties.FirstOrDefault(y => (y.DeveloperId == "hcc") && (y.Key == "allowpasswordreset") && (y.Value == "1")); if (prop != null) { prop.Value = "0"; } HccApp.OrderServices.Orders.Update(order); } catch (Exception ex) { resp.Success = false; resp.Messages = ex.Message; } } return(new PreJsonResult(Web.Json.ObjectToJson(resp))); }