public async Task <IActionResult> Post([FromForm] InformationoperationViewModel model)
        {
            var date      = DateTime.Now;
            var filesname = "null";
            var random    = RandomString(15);

            //ตรวจสอบว่ามี Folder Upload ใน wwwroot มั้ย
            if (!Directory.Exists(_environment.WebRootPath + "/assets" + "//InformationoperationFile//"))
            {
                Directory.CreateDirectory(_environment.WebRootPath + "/assets" + "//InformationoperationFile//"); //สร้าง Folder Upload ใน wwwroot
            }

            ////var BaseUrl = url.ActionContext.HttpContext.Request.Scheme;
            //// path ที่เก็บไฟล์
            var filePath = _environment.WebRootPath + "/assets" + "//InformationoperationFile//";


            foreach (var formFile in model.files.Select((value, index) => new { Value = value, Index = index }))
            ////foreach (var formFile in data.files)
            {
                string filePath2 = formFile.Value.FileName;
                string filename  = Path.GetFileName(filePath2);
                string ext       = Path.GetExtension(filename);

                if (formFile.Value.Length > 0)
                {
                    // using (var stream = System.IO.File.Create(filePath + formFile.Value.FileName))
                    using (var stream = System.IO.File.Create(filePath + random + ext))
                    {
                        await formFile.Value.CopyToAsync(stream);

                        filesname = random + ext;
                    }
                }
            }
            var informationoperationdata = new Informationoperation
            {
                Location = model.Location,
                Name     = model.Name,
                Detail   = model.Detail,
                Tel      = model.Tel,
                Province = model.Province,
                District = model.District,
                File     = filesname,
                //Prefix = model.Prefix,
                CreatedAt = date
            };

            _context.Informationoperations.Add(informationoperationdata);
            _context.SaveChanges();
            return(Ok(informationoperationdata));
        }
        public async Task <IActionResult> Put([FromForm] InformationoperationViewModel request)
        {
            var informationoperation = _context.Informationoperations.Find(request.Id);

            informationoperation.Location = request.Location;
            informationoperation.Name     = request.Name;
            informationoperation.Detail   = request.Detail;
            informationoperation.Tel      = request.Tel;
            informationoperation.Province = request.Province;
            informationoperation.District = request.District;
            _context.Entry(informationoperation).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();

            System.Console.WriteLine("1 : ");
            // <!-- อัพไฟล์  -->
            if (!Directory.Exists(_environment.WebRootPath + "/assets" + "//InformationoperationFile//"))
            {
                Directory.CreateDirectory(_environment.WebRootPath + "/assets" + "//InformationoperationFile//"); //สร้าง Folder Upload ใน wwwroot
            }
            var filePath = _environment.WebRootPath + "/assets" + "//InformationoperationFile//";

            System.Console.WriteLine("2 : ");
            if (request.files != null)
            {
                foreach (var formFile in request.files.Select((value, index) => new { Value = value, Index = index }))
                {
                    var    random    = RandomString(10);
                    string filePath2 = formFile.Value.FileName;
                    string filename  = Path.GetFileName(filePath2);
                    string ext       = Path.GetExtension(filename);
                    System.Console.WriteLine("3 : ");
                    if (formFile.Value.Length > 0)
                    {
                        using (var stream = System.IO.File.Create(filePath + random + filename))
                        {
                            await formFile.Value.CopyToAsync(stream);
                        }
                        var data2 = _context.Informationoperations.Find(request.Id);
                        data2.File = random + filename;
                        System.Console.WriteLine("4 : ");
                        _context.Entry(data2).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        _context.SaveChanges();
                    }
                }
            }
            // <!--END อัพไฟล์  -->
            System.Console.WriteLine("5 : ");
            return(Ok(new { Id = informationoperation.Id, title = informationoperation.Name }));
        }