Ejemplo n.º 1
0
        public ActionResult SaveConnection(string ServerName, string DatabaseName, string UserName, string Password,
                                           string PortNumber = "", string UseSSL = "", string ActivateSSL = "")
        {
            facade = new Fasada();
            try
            {
                facade = new Fasada();
                var dt = facade.GetMysqlScheme(ServerName, DatabaseName, UserName, Password, PortNumber, UseSSL, ActivateSSL);

                var connectionString = facade.GetMySqlConnectionString(ServerName, DatabaseName, UserName, Password,
                                                                       PortNumber, UseSSL, ActivateSSL);

                using (var context = new SkyContext())
                {
                    var dataBaseType =
                        context.DatabaseTypes.Where(a => a.DatabaseTypeID == 1).Select(a => a).FirstOrDefault();
                    connectionString += "[1]";
                    context.ConnectionStrings.Add(new ConnectionString()
                    {
                        Connection = connectionString,
                    });
                    context.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                //log error
                @TempData["TestData"] = exception.Message;
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult RegisterPrivateUser(User user)
 {
     using (var context = new SkyContext())
     {
         user.CreatedAccount = DateTime.Now;
         user.BirthdayDate   = DateTime.Now;
         context.Users.Add(user);
         context.SaveChanges();
     }
     TempData["Registration"] = "Yes";
     return(RedirectToAction("LogIn", "Home"));
 }