public async Task <IActionResult> ProfileUpdate()
        {
            IFormCollection         form;
            object                  obj3    = Request.Form["profile"]; // object
            Profiles                profile = Libs.DeserializeObject <Profiles>(obj3.ToString());
            ReturnResult <Profiles> result  = new ReturnResult <Profiles>();

            try
            {
                ICollection <IFormFile> files          = Request.Form.Files.ToList();
                List <ComputerFile>     lstFilesExists = new List <ComputerFile>();
                List <ComputerFile>     lstFileInfo    = new List <ComputerFile>();
                List <ComputerFile>     lstFiles       = new List <ComputerFile>();

                string path = Libs.GetFullPathDirectoryFileUpload();

                string directoryPathFileUpload = Const.FILE_UPLOAD_DIR + profile.FileCode;

                //string directoryPathFileUpload = Path.Combine(path, profile.FileCode);
                if (!Directory.Exists(directoryPathFileUpload))
                {
                    // FileCode changed
                    //    string[] directories = Directory.GetDirectories(Const.FILE_UPLOAD_DIR);
                    var    profileCheck       = profileBUS.GetProfileByID(profile.ProfileId);
                    string directoryOfProfile = Path.Combine(path, profileCheck.Item.FileCode);
                    if (Directory.Exists(directoryOfProfile))
                    {
                        Directory.Move(directoryOfProfile, directoryPathFileUpload);
                    }
                    else
                    {
                        Directory.CreateDirectory(directoryPathFileUpload);
                    }
                    if (files.Count > 0)
                    {
                        string[] lstFilesDir = Directory.GetFiles(directoryPathFileUpload);
                        if (lstFilesDir.Length > 0)
                        {
                            string[] lstDirFilesUpload = lstFilesDir;
                            foreach (var fileAlreadyExsists in lstDirFilesUpload)
                            {
                                foreach (var file in files)
                                {
                                    if (fileAlreadyExsists.IndexOf(file.FileName) > -1)
                                    {
                                        lstFilesExists.Add(new ComputerFile()
                                        {
                                            FileName  = Path.GetFileName(fileAlreadyExsists),
                                            ProfileId = profile.ProfileId,
                                            Url       = fileAlreadyExsists
                                        });
                                    }
                                }
                            }
                            string overwrite = Request.Form["overwrite"].ToString();
                            if (lstFilesExists.Count > 0)
                            {
                                if (overwrite == "accept")
                                {
                                    foreach (var fileAlreadyExists in lstFilesExists)
                                    {
                                        System.IO.File.Delete(fileAlreadyExists.Url);
                                    }
                                    //    overwrite file already exists
                                    foreach (var file in files)
                                    {
                                        string filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                        FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                    }
                                }
                                else
                                {
                                    var fileResult = new ReturnResult <ComputerFile>()
                                    {
                                        ReturnValue = Libs.SerializeObject(lstFilesExists.Select(item => item.FileName))
                                    };
                                    fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                                    return(Ok(fileResult));
                                }
                            }
                            else
                            {
                                foreach (var file in files)
                                {
                                    var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                    FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                }
                            }
                        }
                        else
                        {
                            foreach (var file in files)
                            {
                                var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                            }
                        }
                        // lấy lại danh sách file đã được tải lên
                        string[] lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);
                        foreach (var fileUrl in lstDirFilesUploaded)
                        {
                            string fileName = Path.GetFileName(fileUrl);
                            foreach (var file in files)
                            {
                                if (fileName.Equals(file.FileName))
                                {
                                    lstFiles.Add(new ComputerFile()
                                    {
                                        FileName   = file.FileName,
                                        Size       = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                                        Url        = fileUrl,
                                        PageNumber = GetNumberOfPdfPages(fileUrl),
                                        CreatedBy  = profile.CreatedBy,
                                        FolderPath = directoryPathFileUpload,
                                        ClientUrl  = Const.FILE_SERVER_FOLDER + profile.FileCode + "/" + HttpUtility.HtmlEncode(fileName)
                                    });
                                }
                            }
                        }

                        result = profileBUS.Update(profile, lstFiles, lstFilesExists, directoryPathFileUpload);
                    }
                    else
                    {
                        // không tải file lên thì chỉ send thông tin hồ sơ
                        result = profileBUS.Update(profile, null, null, directoryPathFileUpload);
                    }
                }
                else
                {
                    if (files.Count > 0)
                    {
                        string[] lstFilesDir = Directory.GetFiles(directoryPathFileUpload);
                        if (lstFilesDir.Length > 0)
                        {
                            string[] lstDirFilesUpload = lstFilesDir;
                            foreach (var fileAlreadyExsists in lstDirFilesUpload)
                            {
                                foreach (var file in files)
                                {
                                    if (fileAlreadyExsists.IndexOf(file.FileName) > -1)
                                    {
                                        lstFilesExists.Add(new ComputerFile()
                                        {
                                            FileName  = Path.GetFileName(fileAlreadyExsists),
                                            ProfileId = profile.ProfileId,
                                            Url       = fileAlreadyExsists
                                        });
                                    }
                                }
                            }
                            string overwrite = Request.Form["overwrite"].ToString();
                            if (lstFilesExists.Count > 0)
                            {
                                if (overwrite == "accept")
                                {
                                    foreach (var fileAlreadyExists in lstFilesExists)
                                    {
                                        System.IO.File.Delete(fileAlreadyExists.Url);
                                    }

                                    //    overwrite file already exists
                                    foreach (var file in files)
                                    {
                                        string filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                        FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                    }
                                }
                                else
                                {
                                    var fileResult = new ReturnResult <ComputerFile>()
                                    {
                                        ReturnValue = Libs.SerializeObject(lstFilesExists.Select(item => item.FileName))
                                    };

                                    fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                                    return(Ok(fileResult));
                                }
                            }
                            else
                            {
                                foreach (var file in files)
                                {
                                    var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                    FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                }
                            }
                        }
                        else
                        {
                            foreach (var file in files)
                            {
                                var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                            }
                        }
                        // lấy lại danh sách file đã được tải lên
                        string[] lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);
                        foreach (var fileUrl in lstDirFilesUploaded)
                        {
                            string fileName = Path.GetFileName(fileUrl);
                            foreach (var file in files)
                            {
                                if (fileName.Equals(file.FileName))
                                {
                                    lstFiles.Add(new ComputerFile()
                                    {
                                        FileName   = file.FileName,
                                        Size       = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                                        Url        = fileUrl,
                                        PageNumber = GetNumberOfPdfPages(fileUrl),
                                        CreatedBy  = profile.CreatedBy,
                                        FolderPath = directoryPathFileUpload,
                                        ClientUrl  = Const.FILE_SERVER_FOLDER + profile.FileCode + "/" + HttpUtility.HtmlEncode(fileName)
                                    });
                                }
                            }
                        }
                        result = profileBUS.Update(profile, lstFiles, lstFilesExists, directoryPathFileUpload);
                    }
                    else
                    {
                        // không tải file lên thì chỉ send thông tin hồ sơ
                        result = profileBUS.Update(profile, null, null, directoryPathFileUpload);
                    }
                }
                // check FileCode was edit ?
                #region FILE UPLOAD
                //if (files.Count > 0)
                //{
                //    string[] lstFilesDir = Directory.GetFiles(directoryPathFileUpload);
                //    if (lstFilesDir.Length > 0)
                //    {
                //        string[] lstDirFilesUpload = lstFilesDir;
                //        foreach (var fileAlreadyExsists in lstDirFilesUpload)
                //        {
                //            foreach (var file in files)
                //            {
                //                if (fileAlreadyExsists.IndexOf(file.FileName) > -1)
                //                {
                //                    lstFilesExists.Add(new ComputerFile()
                //                    {
                //                        FileName = fileAlreadyExsists,
                //                        ProfileId = profile.ProfileId,
                //                        Url = fileAlreadyExsists
                //                    });
                //                }
                //            }
                //        }
                //        string overwrite = Request.Form["overwrite"].ToString();
                //        if (lstFilesExists.Count > 0)
                //        {
                //            if (overwrite == "accept")
                //            {
                //                foreach (var fileAlreadyExists in lstFilesExists)
                //                {
                //                    System.IO.File.Delete(fileAlreadyExists.FileName);
                //                }

                //                //    overwrite file already exists
                //                foreach (var file in files)
                //                {
                //                    string filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                //                    FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                //                }
                //            }
                //            else
                //            {
                //                var fileResult = new ReturnResult<ComputerFile>()
                //                {
                //                    ReturnValue = Libs.SerializeObject(lstFilesExists.Select(item => item.FileName))
                //                };

                //                fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                //                return Ok(fileResult);
                //            }
                //        }
                //        else
                //        {
                //            foreach (var file in files)
                //            {
                //                var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                //                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                //            }
                //        }
                //    }
                //    else
                //    {
                //        foreach (var file in files)
                //        {
                //            var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                //            FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                //        }
                //    }
                //    // lấy lại danh sách file đã được tải lên
                //    string[] lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);

                //    foreach (var fileUrl in lstDirFilesUploaded)
                //    {
                //        string fileName = Path.GetFileName(fileUrl);
                //        foreach (var file in files)
                //        {
                //            if (fileName.Equals(file.FileName))
                //            {
                //                lstFiles.Add(new ComputerFile()
                //                {
                //                    FileName = file.FileName,
                //                    Size = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                //                    Url = fileUrl,
                //                    PageNumber = GetNumberOfPdfPages(fileUrl),
                //                    CreatedBy = profile.CreatedBy,
                //                    FolderPath = directoryPathFileUpload
                //                });
                //            }
                //        }
                //    }

                //    result = profileBUS.Update(profile, lstFiles, lstFilesExists, directoryPathFileUpload);
                //}
                //else
                //{
                //    // không tải file lên thì chỉ send thông tin hồ sơ
                //    result = profileBUS.Update(profile, null, null, directoryPathFileUpload);
                //}
                #endregion
                return(Ok(result));
            }
            catch (Exception ex)
            {
                result.Failed("1", ex.Message);
                return(Ok(result));
            }
        }