public SearchServices(
     mbEntities dataContext,
     IUnitOfWork unitOfWork)
     : base(unitOfWork)
 {
     _dataContext = dataContext;
 }
 public UpgradeServices(
     mbEntities dataContext)
 {
     _dataContext = dataContext;
 }
        public ActionResult Step3()
        {
            if (Session[SessionMailInfoKey] != null)
                ViewData[ViewDataKeys.GlobalMessages.Success] = "Successfully connected to mail server";

            SQLInstallViewModel sqlInfo = Session[SessionSqlInfoKey] as SQLInstallViewModel;
            if (sqlInfo != null)
            {
                Settings.DatabaseServer = sqlInfo.DatabaseServer;
                Settings.DatabaseName = sqlInfo.DatabaseName;
                Settings.UseIntegratedSecurity = sqlInfo.UseIntegratedSecurity;
                if (!sqlInfo.UseIntegratedSecurity)
                {
                    Settings.DatabaseLogin = sqlInfo.DatabaseLogin;
                    Settings.DatabasePassword = sqlInfo.DatabasePassword;
                }

                string connectionString =
                    Settings.ConnectionStringTemplate
                            .Replace("{dbserver}", sqlInfo.DatabaseServer)
                            .Replace("{integratedsecurity}", sqlInfo.UseIntegratedSecurity.ToString())
                            .Replace("{dbname}", sqlInfo.DatabaseName)
                            .Replace("{dblogin}", sqlInfo.DatabaseLogin)
                            .Replace("{dbpassword}", sqlInfo.DatabasePassword);

                string entityConnectionString = Settings.EntityConnectionStringTemplate.Replace("{CONNECTIONSTRING}", connectionString);
                mbEntities dataContext = new mbEntities(entityConnectionString);

                Config automatedEmail = dataContext.Configs.First(item => item.Name.Equals("AutomatedFromEmail"));
                automatedEmail.Value = "no-reply@" + Request.Url.Host;

                Config boardUrl = dataContext.Configs.First(item => item.Name.Equals("BoardURL"));
                boardUrl.Value = Request.Url.Host;

                dataContext.SaveChanges();
            }

            MailInstallViewModel mailInfo = Session[SessionMailInfoKey] as MailInstallViewModel;
            if (mailInfo != null)
            {
                Settings.SmtpServer = mailInfo.MailServerAddress;
                Settings.SmtpPort = mailInfo.PortNumber;
                Settings.SmtpUseDefaultCredentials = mailInfo.MailUseDefaultCredentials;
                if (!mailInfo.MailUseDefaultCredentials)
                {
                    Settings.SmtpLogin = mailInfo.MailLogin;
                    Settings.SmtpPassword = mailInfo.MailPassword;
                }
            }

            ViewData["StepNumber"] = 3;
            return View();
        }