public ActionResult UserAccount(UserAccountViewModel model) { if (!ModelState.IsValid) { model.errMessage = "Please enter valid information."; return(View(model)); } Account account = Session["account"] as Account; bool emailChanged = model.acctEmail != account.Email; bool phoneChanged = model.acctPhoneNumber != account.PhoneNumber; CheckValidInfoResult result = null; if (emailChanged || phoneChanged) { result = AccountDB.CheckValidInfo(model.acctEmail, model.acctPhoneNumber); } if (emailChanged && result.EmailCount > 0) { model.errMessage = "Email already exists. Please enter a new one."; return(View(model)); } if (phoneChanged && result.PhoneNumberCount > 0) { model.errMessage = "Phone Number already exists. Please enter a new one."; return(View(model)); } Account updatedAccount = new Account { Name = model.acctName, Email = model.acctEmail, PhoneNumber = model.acctPhoneNumber, Carrier = model.acctCarrier, AccountId = account.AccountId }; if (model.isEmailNotiType) { updatedAccount.NotificationType |= NotificationType.Email; } if (model.isTextNotiType) { updatedAccount.NotificationType |= NotificationType.SMS; } if (model.isSYLocation) { updatedAccount.Location |= Location.Sylvania; } if (model.isRCLocation) { updatedAccount.Location |= Location.RockCreek; } if (model.isCASLocation) { updatedAccount.Location |= Location.Cascade; } if (model.isSELocation) { updatedAccount.Location |= Location.Southeast; } AccountDB.UpdateAccount(updatedAccount); model.message = "Saved successfully"; account.Name = updatedAccount.Name; account.Email = updatedAccount.Email; account.PhoneNumber = updatedAccount.PhoneNumber; account.Carrier = updatedAccount.Carrier; Session["account"] = account; return(View(model)); }