public ActionResult ChangeUsername(SettingUsernameViewModel postForm) { string response; bool change = settingsManager.ChangeUsername(postForm, out response); if (change) { Session["updateMessage"] = response; } else { Session["errorMessage"] = response; } return(RedirectToAction("ChangeUsername", "Settings")); }
public bool ChangeUsername(SettingUsernameViewModel settingForm, out string outputMessage) { string emailAddress = HttpContext.Current.User.Identity.Name.ToString(); Account userAccount = global.GetAccount(emailAddress); if (userAccount != null) { if (userAccount.Username.ToLower() == settingForm.OldUsername.ToLower()) { if (global.IsUniqueUsername(settingForm.NewUsername)) { try { userAccount.Username = settingForm.NewUsername; db.SaveChanges(); outputMessage = string.Format(Resources.Processing.ProcessSettingsConfirmed, "username"); return(true); } catch { outputMessage = Resources.Processing.ProcessError; return(false); } } else { outputMessage = Resources.Processing.ProcessUsernameExists; return(false); } } else { outputMessage = Resources.Processing.ProcessUsernameNotFound; return(false); } } outputMessage = Resources.Processing.ProcessError; return(false); }