public async Task <IActionResult> UpdateBookmarkAsync(string bookmark, string text, IFormFile image)
        {
            string path = null;

            if (image != null)
            {
                if (Path.GetExtension(image.FileName).Equals(".png") || Path.GetExtension(image.FileName).Equals(".jpg"))
                {
                    path = _appEnvironment.WebRootPath + "/Images/" + image.FileName;
                    try
                    {
                        await FolderWork.SaveImage(image, path);

                        _logger.LogInformation($"Изображение {image.FileName} сохранено по пути {path}.");
                    }
                    catch (Exception e)
                    {
                        _logger.LogError($"Не удалось сохранить изображение {image.FileName}.");
                        WriteExceptionInLog(e);
                        ViewBag.Messages = e.Message.ToString();
                        ViewBag.LongText = wordDocument.GetTextFromDocument();
                        return(View());
                    }
                }
                else
                {
                    ViewBag.Messages = "Неверный формат файла. Должен быть PNG или JPG";
                    ViewBag.LongText = wordDocument.GetTextFromDocument();
                    return(View());
                }
            }

            try
            {
                if (string.IsNullOrWhiteSpace(path))
                {
                    _logger.LogInformation($"Начато изменение закладки {bookmark} на {text}");
                    wordDocument.EditTextInBookmark(bookmark, text);
                    _logger.LogInformation($"Завершилось изменение закладки {bookmark} на {text}");
                }
                else
                {
                    _logger.LogInformation($"Начато изменение изображения закладки {bookmark}");
                    wordDocument.EditImageInBookmark(bookmark, path);
                    _logger.LogInformation($"Завершилось изменение изображения закладки {bookmark}");
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Message {e.Message}");
                WriteExceptionInLog(e);
                ViewBag.Messages = e.Message.ToString();
                return(Redirect("EditLinks"));
            }
            return(Redirect("EditLinks"));
        }
        public async Task <IActionResult> Index(string word, string text, string linkType, IFormFile image, string oneOrAll, int count = default)
        {
            try
            {
                string path = null;
                if (image != null)
                {
                    if (Path.GetExtension(image.FileName).Equals(".png") || Path.GetExtension(image.FileName).Equals(".jpg"))
                    {
                        path = _appEnvironment.WebRootPath + "/Images/" + image.FileName;
                        try
                        {
                            await FolderWork.SaveImage(image, path);

                            _logger.LogInformation($"Изображение {image.FileName} сохранено по пути {path}.");
                        }
                        catch (Exception e)
                        {
                            _logger.LogError($"Не удалось сохранить изображение {image.FileName}.");
                            WriteExceptionInLog(e);
                            ViewBag.Messages = e.Message.ToString();
                            ViewBag.LongText = wordDocument.GetTextFromDocument();
                            return(View());
                        }
                    }
                    else
                    {
                        ViewBag.Messages = "Неверный формат файла. Должен быть PNG или JPG";
                        ViewBag.LongText = wordDocument.GetTextFromDocument();
                        return(View());
                    }
                }

                if (!string.IsNullOrWhiteSpace(text) & !string.IsNullOrWhiteSpace(word) & !string.IsNullOrWhiteSpace(linkType))
                {
                    if (linkType.Equals("bookmark"))
                    {
                        try
                        {
                            _logger.LogInformation($"Начато создание закладки для текста с параметрами {text}, {word}");
                            if (oneOrAll.Equals("all"))
                            {
                                wordDocument.CreateBookmarksForText(word, text, count);
                            }
                            else if (oneOrAll.Equals("one"))
                            {
                                wordDocument.CreateBookmarkForOneWord(word, text);
                            }
                            _logger.LogInformation($"Завершилось создание закладки для текста с параметрами {text}, {word}");
                        }
                        catch (Exception e)
                        {
                            _logger.LogError($"Message {e.Message}");
                            WriteExceptionInLog(e);
                            ViewBag.Messages = e.Message.ToString();
                            ViewBag.LongText = wordDocument.GetTextFromDocument();
                            return(View());
                        }
                    }
                    else if (linkType.Equals("hyperlink"))
                    {
                        try
                        {
                            _logger.LogInformation($"Начато создание гиперссылки для текста с параметрами {text}, {word}");
                            if (oneOrAll.Equals("all"))
                            {
                                wordDocument.CreateHyperlinksForText(word, text, count);
                            }
                            else if (oneOrAll.Equals("one"))
                            {
                                wordDocument.CreateHyperlinkForOneWord(word, text);
                            }
                            _logger.LogInformation($"Завершилось создание гиперссылки для текста с параметрами {text}, {word}");
                        }
                        catch (Exception e)
                        {
                            _logger.LogError($"Message {e.Message}");
                            WriteExceptionInLog(e);
                            ViewBag.Messages = e.Message.ToString();
                            ViewBag.LongText = wordDocument.GetTextFromDocument();
                            return(View());
                        }
                    }
                }
                else if (!string.IsNullOrWhiteSpace(path) & !string.IsNullOrWhiteSpace(text) & !string.IsNullOrWhiteSpace(linkType))
                {
                    if (linkType.Equals("hyperlink"))
                    {
                        try
                        {
                            _logger.LogInformation($"Начато создание гиперссылки для изображения с параметрами {text}, {path}");
                            wordDocument.CreatHyperlinkForImage(path, text);
                            _logger.LogInformation($"Завершилось создание гиперссылки для изображения с параметрами {text}, {path}");
                        }
                        catch (Exception e)
                        {
                            _logger.LogError($"Message {e.Message}");
                            WriteExceptionInLog(e);
                            ViewBag.Messages = e.Message.ToString();
                            ViewBag.LongText = wordDocument.GetTextFromDocument();
                            return(View());
                        }
                    }
                }
                else if (!string.IsNullOrWhiteSpace(path) & !string.IsNullOrWhiteSpace(word) & !string.IsNullOrWhiteSpace(linkType))
                {
                    if (linkType.Equals("bookmark"))
                    {
                        try
                        {
                            _logger.LogInformation($"Начато создание закладки для изображения с параметрами {text}, {path}");
                            if (oneOrAll.Equals("all"))
                            {
                                wordDocument.CreateBookmarksForImage(path, word, count);
                            }
                            else if (oneOrAll.Equals("one"))
                            {
                                wordDocument.CreateBookmarkByImgeForOneWord(path, word);
                            }
                            _logger.LogInformation($"Завершилось создание закладки для изображения с параметрами {text}, {path}");
                        }
                        catch (Exception e)
                        {
                            _logger.LogError($"Message {e.Message}");
                            WriteExceptionInLog(e);
                            ViewBag.Messages = e.Message.ToString();
                            ViewBag.LongText = wordDocument.GetTextFromDocument();
                            return(View());
                        }
                    }
                }



                ViewBag.Messages = wordDocument.Messages;
                ViewBag.LongText = wordDocument.GetTextFromDocument();
                return(View());
            }
            catch (Exception e)
            {
                _logger.LogError($"Message {e.Message}");
                WriteExceptionInLog(e);
                ViewBag.Messages = e.Message.ToString();
                ViewBag.LongText = wordDocument.GetTextFromDocument();
                return(View());
            }
        }