public ActionResult UpgradeDb() { // Work out this install can be upgraded, and if not redirect var previousVersionNo = AppHelpers.PreviousVersionNo(); var currentVersionNo = AppHelpers.GetCurrentVersionNo(); var installerResult = new InstallerResult { Successful = true, Message = string.Format("Upgrade to v{0} was successful", currentVersionNo) }; // Can't upgrade so redirect if (Convert.ToDouble(previousVersionNo) < 1.3d) { return(RedirectToAction("ManualUpgradeNeeded")); } //***** Old version is v1.3 or greater so we can run the installer **** // Firstly add any new tables needed via the SQL // Get the SQL file and if it exists then run it var dbFilePath = Server.MapPath(InstallerHelper.GetUpdateDatabaseFilePath(currentVersionNo)); // See whether this version needs a table update if (System.IO.File.Exists(dbFilePath)) { // There is a file so update the database with the new tables installerResult = _installerService.CreateDbTables(null, dbFilePath, currentVersionNo); if (!installerResult.Successful) { // Was an error creating the tables return(RedirectToCreateDb(installerResult, GenericMessages.danger)); } } // Tables created or updated - So now update all the data installerResult = UpdateData(currentVersionNo, previousVersionNo, installerResult); // See if upgrade was successful or not if (installerResult.Successful) { TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel { Message = installerResult.OnScreenMessage, MessageType = GenericMessages.success }; // Finally update the web.config to the new version UpdateWebConfigVersionNo(installerResult, currentVersionNo); return(RedirectToAction("Complete")); } return(RedirectToCreateDb(installerResult, GenericMessages.danger)); }