public async Task <IActionResult> Create(BookFormModel model)
        {
            if (await this.books.UniqueCheckAsync(model.BookTitle, model.AuthorName))
            {
                this.TempData.AddWarningMessage(string.Format(TempDataAlreadyExistsText, ModelName, model.BookTitle));

                return(this.RedirectToAction(nameof(this.Create)));
            }

            model.BookDescription = this.html.Sanitize(model.BookDescription);

            string savePath;

            if (model.ImageUrl != null)
            {
                var path = Path.Combine(ImageFolderName, BooksImageFolderName, $"{Guid.NewGuid()}.jpg");

                if (!ImageDownloaderExtensions.Download(model.ImageUrl, path))
                {
                    this.TempData.AddWarningMessage(string.Format(TempDataWrongUrlText, ModelName));
                    return(this.RedirectToAction(nameof(this.Create)));
                }
                path = path.Replace("\\", "/");

                savePath = string.Format(SavePath, path);
            }
            else
            {
                savePath = DefaultImagePath;
            }

            await this.books.CreateAsync(
                model.AuthorName,
                model.BookTitle,
                model.BookDescription,
                model.CityIssued,
                model.Press,
                model.Department,
                model.PublishDate,
                DateTime.UtcNow,
                model.Pages,
                model.Genre,
                savePath,
                model.Language);

            this.TempData.AddSuccessMessage(string.Format(TempDataCreateCommentText, ModelName, EndingLetterA));

            return(this.RedirectToAction(nameof(this.Books)));
        }
        public async Task <IActionResult> Edit(int id, BookFormModel model)
        {
            string savePath = null;

            if (model.ImageUrl != null)
            {
                var path = Path.Combine(ImageFolderName, BooksImageFolderName, $"{Guid.NewGuid()}.jpg");

                if (!ImageDownloaderExtensions.Download(model.ImageUrl, path))
                {
                    this.TempData.AddWarningMessage(string.Format(TempDataWrongUrlText, ModelName));

                    return(this.RedirectToAction(nameof(this.Create)));
                }

                path = path.Replace("\\", "/");

                savePath = $"/{path}";
            }

            model.BookDescription = this.html.Sanitize(model.BookDescription);

            await this.books.EditAsync(
                id,
                model.AuthorName,
                model.BookTitle,
                model.BookDescription,
                model.CityIssued,
                model.Press,
                model.Department,
                model.PublishDate,
                model.Pages,
                model.Genre,
                savePath,
                model.Language);

            this.TempData.AddSuccessMessage(string.Format(TempDataEditCommentText, ModelName, EndingLetterA));

            return(this.RedirectToAction(nameof(this.Books)));
        }