public ActionResult ChangeContactInfo() { SessionToViewBag(); string emailAddress = HttpContext.User.Identity.Name.ToString(); Account referenceAccount = global.GetAccount(emailAddress); SettingContactViewModel baseModel = (referenceAccount != null) ? new SettingContactViewModel(referenceAccount.State) : new SettingContactViewModel(); return(View(baseModel)); }
public ActionResult ChangeContactInfo(SettingContactViewModel postForm) { string response; bool change = settingsManager.ChangeContactInformation(postForm, out response); if (change) { Session["updateMessage"] = response; } else { Session["errorMessage"] = response; } return(RedirectToAction("ChangeContactInfo", "Settings")); }
public bool ChangeContactInformation(SettingContactViewModel settingForm, out string outputMessage) { string emailAddress = HttpContext.Current.User.Identity.Name.ToString(); Account userAccount = global.GetAccount(emailAddress); if (userAccount != null) { try { if (!string.IsNullOrWhiteSpace(settingForm.ContactName)) { userAccount.ContactName = settingForm.ContactName; db.SaveChanges(); } if (!string.IsNullOrWhiteSpace(settingForm.Country)) { userAccount.Country = settingForm.Country; db.SaveChanges(); } if (!string.IsNullOrWhiteSpace(settingForm.Phone)) { userAccount.Phone = settingForm.Phone; db.SaveChanges(); } if (!string.IsNullOrWhiteSpace(settingForm.State)) { userAccount.State = settingForm.State; db.SaveChanges(); } if (!string.IsNullOrWhiteSpace(settingForm.City)) { userAccount.City = settingForm.City; db.SaveChanges(); } outputMessage = string.Format(Resources.Processing.ProcessSettingsConfirmed, "contact information"); return(true); } catch { outputMessage = Resources.Processing.ProcessError; return(false); } } outputMessage = Resources.Processing.ProcessError; return(false); }