public ActionResult ExternalDeattach(long id)
        {
            var pageRepository = new PagesRepository();

            var page = pageRepository.GetById(id);

            page.Content = null;
            page.ExternalId = null;

            pageRepository.Update(page);

            return RedirectToAction("Details", new { id });
        }
        public ActionResult Edit(EditPageViewModel model)
        {
            try
            {
                var tagsRepository = new TagsRepository();

                var pagesRepository = new PagesRepository();
                var originalPage = pagesRepository.GetById(model.Id);

                if (model.SelectedTags != null)
                {
                    var tags = tagsRepository.GetByStringIds(model.SelectedTags);
                    originalPage.Tags = new List<Tag>(tags);
                }
                else
                {
                    originalPage.Tags = null;
                }

                originalPage.Name = model.Name;
                originalPage.Description = model.Description;
                originalPage.Content = model.Content;
                originalPage.ExternalId = model.ExternalId;

                pagesRepository.Update(originalPage);

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
        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 });
        }