public ActionResult EditAddress(AddressModel addressModel) { try { LoginHelper.CheckAccess(Session); } catch (Exception) { return(RedirectToAction("Login", "Login")); } AddressHelper addressHelper = new AddressHelper(); var userProfileId = (int)Session["userProfileId"]; var addressHandler = new AddressHandler(); var oldAddress = addressHandler.GetForUserProfile(userProfileId); if (!oldAddress.CompletedRequest) { return(RedirectToAction("Index", "Error", new { errorMessage = oldAddress.ErrorMessage.Replace(' ', '-') })); } if (!addressHelper.CheckAddress(addressModel)) { ViewBag.AddressMessage = addressHelper.AddressMessage; var newAddressModel = addressHelper.GetAddressModel(oldAddress.Entity.AddressId); return(View("EditAddress", newAddressModel)); } if (addressHelper.NoChanges(oldAddress.Entity, addressModel)) { ViewBag.AddressMessage = MessageConstants.NoChangesMade; var newAddressModel = addressHelper.GetAddressModel(oldAddress.Entity.AddressId); return(View("EditAddress", newAddressModel)); } var entity = addressHelper.ToDataEntity(oldAddress.Entity.AddressId, userProfileId, addressModel); var addressResponse = addressHandler.Update(entity); if (!addressResponse.CompletedRequest) { return(RedirectToAction("Index", "Error", new { errorMessage = addressResponse.ErrorMessage.Replace(' ', '-') })); } return(RedirectToAction("UserProfile", "Account")); }