Exemplo n.º 1
0
 public IActionResult fristFolder(string userName, int id)
 {
     try
     {
         var    db        = new ConMySQL();
         var    pathfrist = "/uploads";
         string sqlfile   = $"INSERT INTO DataFile(NameFile, Path, Type ,IdUser) VALUES ('{userName}','{pathfrist}', 'Folder', '{id}')";
         db.executeQuery(sqlfile);
         // Console.WriteLine(sqlfile);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 2
0
        public IActionResult Register([FromBody] User data)
        {
            ResponseErr res = new ResponseErr();

            try
            {
                var    db      = new ConMySQL();
                var    pathsql = "/uploads/" + data.userName;
                string sqluser = $"INSERT INTO User(UserName, Password, Email) VALUES ('{data.userName}','{data.passWord}','{data.email}')";
                db.executeQuery(sqluser);

                string    sqlgetuser   = $"SELECT * FROM User WHERE UserName = '******'";
                DataTable dataTableGet = db.getData(sqlgetuser);
                User      obj          = new User();
                foreach (DataRow dr in dataTableGet.Rows)
                {
                    obj.id = Convert.ToInt32(dr["id"]);
                }
                Console.WriteLine(obj.id);

                // Console.WriteLine(pathsql);
                // string sqlfile = $"INSERT INTO DataFile(NameFile, Path, Type ,IdUser) VALUES ('{data.userName}','{pathsql}', 'Folder', '{obj.id}')";
                // Console.WriteLine(sqlfile);
                // db.executeQuery(sqlfile);
                var pathFristFolder = "/" + data.userName;
                fristFolder(data.userName, obj.id);

                // Console.WriteLine(data.userName);
                string startupPath = Environment.CurrentDirectory;
                string path        = startupPath + "/wwwroot/uploads/" + data.userName;
                Directory.CreateDirectory(path);

                res.msg = "okay";
                return(Ok(res));
            }
            catch (Exception ex)
            {
                res.msg  = ex.Message;
                res.data = data;
                // return res;
                return(BadRequest(res));
            }
        }