// GET: BaseLayers/Create
        public async Task<ActionResult> ExternalAttach(long id)
        {
            var tildaClient = new TildaClient(Settings.Default.PublicKey, Settings.Default.SecretKey);

            var pages = await tildaClient.GetPagesList(Settings.Default.TildaProjectId);

            var pageRepository = new PagesRepository();
            var page = pageRepository.GetById(id);
            

            ViewBag.ListOfTildaPages = pages.Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Title,
                Selected = page.ExternalId != null && string.Equals(x.Id, page.ExternalId)
            });

            var model = new ExternalAttachViewModel()
            {
                Id = id,
                PageId = !string.IsNullOrEmpty(page.ExternalId) ? long.Parse(page.ExternalId) : (long?)null
            };

            return PartialView(model);
        }
        public async Task<ActionResult> ExternalAttach(ExternalAttachViewModel model)
        {
            var pageRepository = new PagesRepository();

            var page = pageRepository.GetById(model.Id);

            var tildaClient = new TildaClient(Settings.Default.PublicKey, Settings.Default.SecretKey);
            var tildaPage = await tildaClient.GetPageFull(model.PageId.Value);

            page.Content = tildaPage.Html;
            page.ExternalId = tildaPage.Id;

            pageRepository.Update(page);

            return RedirectToAction("Details", new { id = model.Id });
        }