コード例 #1
0
        public ActionResult UpdateHome(string description, IFormFile file)
        {
            HotelModel hotelModel = new HotelModel(connectionString);

            if (description != null)
            {
                hotelModel.UpdateHome(description);
            }

            ContentPageModel    contentpageModel = new ContentPageModel(connectionString);
            IList <ContentPage> content          = contentpageModel.GetAllContentPage();

            string urlimage          = "";
            var    path              = "./images/";
            var    pathClient        = "../../../Client/Presentation/wwwroot/images/";
            string folderFiles       = Path.Combine(environment.WebRootPath, path);
            string folderFilesClient = Path.Combine(environment.WebRootPath, pathClient);

            if (file != null)
            {
                contentpageModel.SaveImage(file, folderFiles);
                contentpageModel.SaveImage(file, folderFilesClient);
                urlimage = "/images/" + file.FileName;
            }

            for (int i = 0; i < content.Count; i++)
            {
                if (content[i].referentpage.Equals("home"))
                {
                    if (file == null)
                    {
                        urlimage = content[i].urlimage;
                    }
                    ContentPageModel contentPageNew = new ContentPageModel(connectionString);
                    contentPageNew.urlimage = content[i].urlimage;
                    contentpageModel        = contentPageNew;
                }
            }
            contentpageModel.UpdateContentPageHotel(urlimage, "home");
            return(View("ModifyPage", "ModifyPage"));
        }