Beispiel #1
0
 public UnitOfWork()
 {
     //load in the bindings
     _kernel = new StandardKernel();
     _kernel.Load(new NinjectRepositoryBindings());
     _context = new SDBOAppContext();
     _parms   = new Ninject.Parameters.ConstructorArgument("context", _context);
 }
Beispiel #2
0
 public UnitOfWork()
 {
     //load in the bindings
     _kernel = new StandardKernel();
     _kernel.Load(new NinjectRepositoryBindings());
     _context = new SDBOAppContext();
     _parms = new Ninject.Parameters.ConstructorArgument("context", _context);
 }
 public UnitOfService()
 {
     //load in the bindings
     _kernel = new StandardKernel();
     _kernel.Load(Assembly.GetExecutingAssembly());
     _context = new UnitOfWork();
     _parms = new Ninject.Parameters.ConstructorArgument("context", _context);
 }
Beispiel #4
0
 /// <summary>
 /// Unit Test Constructor
 /// </summary>
 /// <param name="unitOfWork"></param>
 public UnitOfService(IUnitOfWork unitOfWork)
 {
     //load in the bindings
     _kernel = new StandardKernel();
     _kernel.Load(Assembly.GetExecutingAssembly());
     _context = unitOfWork;
     _parms   = new Ninject.Parameters.ConstructorArgument("context", _context);
 }
Beispiel #5
0
        public ActionResult Step3(string username, string email)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                ModelState.AddModelError("username", "Enter an admin username");
            }

            if (string.IsNullOrWhiteSpace(username) || !RegEx.IsValidEmail(email))
            {
                ModelState.AddModelError("email", "Enter a valid email address");
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            string password       = Randoms.RandomPassword();
            string salt           = Randoms.CreateSalt();
            string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password + salt, "MD5");

            string connectionString = Settings.EntityConnectionString;
            var    param            = new Ninject.Parameters.Parameter("connectionString", connectionString, false);

            var    date      = DateTime.UtcNow;
            string ipAddress = HttpContext.Request.UserHostAddress;

            User adminUser = _userRepository.Get().FirstOrDefault();

            adminUser.Email         = email;
            adminUser.LastLoginIP   = ipAddress;
            adminUser.Password      = hashedPassword;
            adminUser.PasswordSalt  = salt;
            adminUser.Username      = username;
            adminUser.UsernameLower = username.ToLower();
            adminUser.RegisterIP    = ipAddress;

            _userRepository.Update(adminUser);

            // If the Smtp server is 'mail.yourdomain.com', that means the user didn't specify mail settings
            // should probably store a value in the session indicating if they specified mail settings
            if (!Settings.SmtpServer.Equals("mail.yourdomain.com"))
            {
                using (SmtpClient smtp = Settings.GetSmtpClient())
                {
                    try
                    {
                        smtp.Send("no-reply@" + Request.Url.Host,
                                  email,
                                  "mesoBoard Installation Complete",
                                  "Admin user created" + Environment.NewLine +
                                  "Username: "******"Password: "******"Couldn't send email. Please store the login information below for your records";
                    }
                }
            }
            else
            {
                ViewData[ViewDataKeys.GlobalMessages.Notice] = "Mail server settings were not given. No email was sent with login information. Please store the login information below for your records";
            }

            ViewData["Username"] = username;
            ViewData["Password"] = password;
            ViewData["Email"]    = email;
            ViewData[ViewDataKeys.GlobalMessages.Success] = "mesoBoard installation complete";

            try
            {
                SiteConfig.UpdateCache();
            }
            catch
            {
                ViewData[ViewDataKeys.GlobalMessages.Notice] = "Configuration Cache did not update. Please update manually through the Admin Control Panel";
            }

            Settings.IsInstalled = true;
            return(View("InstallationComplete"));
        }
        public ActionResult Step3(string username, string email)
        {
            if (string.IsNullOrWhiteSpace(username))
                ModelState.AddModelError("username", "Enter an admin username");

            if (string.IsNullOrWhiteSpace(username) || !RegEx.IsValidEmail(email))
                ModelState.AddModelError("email", "Enter a valid email address");

            if (!ModelState.IsValid)
                return View();

            string password = Randoms.RandomPassword();
            string salt = Randoms.CreateSalt();
            string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password + salt, "MD5");

            string connectionString = Settings.EntityConnectionString;
            var param = new Ninject.Parameters.Parameter("connectionString", connectionString, false);

            var date = DateTime.UtcNow;
            string ipAddress = HttpContext.Request.UserHostAddress;

            User adminUser = _userRepository.Get().FirstOrDefault();

            adminUser.Email = email;
            adminUser.LastLoginIP = ipAddress;
            adminUser.Password = hashedPassword;
            adminUser.PasswordSalt = salt;
            adminUser.Username = username;
            adminUser.UsernameLower = username.ToLower();
            adminUser.RegisterIP = ipAddress;

            _userRepository.Update(adminUser);

            // If the Smtp server is 'mail.yourdomain.com', that means the user didn't specify mail settings
            // should probably store a value in the session indicating if they specified mail settings
            if (!Settings.SmtpServer.Equals("mail.yourdomain.com"))
            {
                using (SmtpClient smtp = Settings.GetSmtpClient())
                {
                    try
                    {
                        smtp.Send("no-reply@" + Request.Url.Host,
                            email,
                            "mesoBoard Installation Complete",
                            "Admin user created" + Environment.NewLine +
                            "Username: "******"Password: "******"Couldn't send email. Please store the login information below for your records";
                    }
                }
            }
            else
                ViewData[ViewDataKeys.GlobalMessages.Notice] = "Mail server settings were not given. No email was sent with login information. Please store the login information below for your records";

            ViewData["Username"] = username;
            ViewData["Password"] = password;
            ViewData["Email"] = email;
            ViewData[ViewDataKeys.GlobalMessages.Success] = "mesoBoard installation complete";

            try
            {
                SiteConfig.UpdateCache();
            }
            catch
            {
                ViewData[ViewDataKeys.GlobalMessages.Notice] = "Configuration Cache did not update. Please update manually through the Admin Control Panel";
            }

            Settings.IsInstalled = true;
            return View("InstallationComplete");
        }