public IActionResult CreateMiniSlider()
        {
            if (!AuthCheck())
            {
                return(RedirectToAction("Login", "Account", new { area = "Admin" }));
            }
            var sliderDto = new AdminMiniSliderDto();

            sliderDto.PhotoAltTag = "tag";
            return(PartialView(sliderDto));
        }
        public IActionResult UpdateMiniSlider(AdminMiniSliderDto dto)
        {
            if (!AuthCheck())
            {
                return(RedirectToAction("Login", "Account", new { area = "Admin" }));
            }
            string messages = string.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors).Select(v => v.ErrorMessage + " " + v.Exception));

            try
            {
                if (ModelState.IsValid)
                {
                    var allowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".bmp" };

                    if (dto.SliderPhoto != null)
                    {
                        FileInfo fs  = new FileInfo(dto.SliderPhoto.FileName);
                        string   ext = Path.GetExtension(fs.Extension);

                        if (!allowedExtensions.Contains(ext.ToLower()))
                        {
                            HttpContext.Session.SetString("warning", "Lütfen sadece .jpg, .jpeg, .bmp veya .png uzantılı resim yükleyiniz.");
                            return(RedirectToAction("MiniSliderList"));
                        }
                    }

                    var targetProduct = _productRepo.GetProductWithNameTR(dto.TargetProductName);
                    if (targetProduct == null)
                    {
                        HttpContext.Session.SetString("warning", "Hedef ürün bulunamadı. Lütfen hedef ürün adını doğru giriniz.");
                        return(RedirectToAction("MiniSliderList"));
                    }

                    dto.IsActive        = true;
                    dto.TargetProductId = targetProduct.Id;

                    string page    = dto.Culture.Equals("tr") ? "sayfa" : "page";
                    string categor = dto.Culture.Equals("tr") ? "kategoriler" : "categories";
                    string bran    = dto.Culture.Equals("tr") ? "markalar" : "brands";
                    string prodeta = dto.Culture.Equals("tr") ? "urun-detay" : "product-detail";

                    if (dto.Culture.Equals("tr"))
                    {
                        dto.PhotoAltTag = targetProduct.PhotoAltTagTR;
                        dto.SliderHref  =
                            $"/{dto.Culture}/{prodeta}/{targetProduct.Brand.BandNameUrl}/{targetProduct.TopCategory.TopCategoryNameUrlTR}/{targetProduct.MiddleCategory?.MiddleCategoryNameUrlTR}/{targetProduct.SubCategory?.SubCategoryNameUrlTR}/{targetProduct.ProductNameUrlTR}";
                    }
                    else if (dto.Culture.Equals("ru"))
                    {
                        dto.PhotoAltTag = targetProduct.PhotoAltTagRU;
                        dto.SliderHref  =
                            $"/{dto.Culture}/{prodeta}/{targetProduct.Brand.BandNameUrl}/{targetProduct.TopCategory.TopCategoryNameUrlEN}/{targetProduct.MiddleCategory?.MiddleCategoryNameUrlEN}/{targetProduct.SubCategory?.SubCategoryNameUrlEN}/{targetProduct.ProductNameUrlEN}";
                    }
                    else
                    {
                        dto.PhotoAltTag = targetProduct.PhotoAltTagEN;
                        dto.SliderHref  =
                            $"/{dto.Culture}/{prodeta}/{targetProduct.Brand.BandNameUrl}/{targetProduct.TopCategory.TopCategoryNameUrlEN}/{targetProduct.MiddleCategory?.MiddleCategoryNameUrlEN}/{targetProduct.SubCategory?.SubCategoryNameUrlEN}/{targetProduct.ProductNameUrlEN}";
                    }
                    dto.SliderHref = dto.SliderHref.Replace("///", "/", StringComparison.Ordinal);
                    dto.SliderHref = dto.SliderHref.Replace("//", "/", StringComparison.Ordinal);

                    var  miniSliderDb = _mapper.Map <MiniSlider>(dto);
                    bool a            = _miniSliderRepo.UpdateEntity(miniSliderDb);

                    bool b = true;

                    if (dto.SliderPhoto != null)
                    {
                        b = ProcessMiniSliderPhoto(dto.SliderPhoto, miniSliderDb.Id);
                    }
                    if (a && b)
                    {
                        HttpContext.Session.SetString("success", "Mini Slider Güncelleme işlemi başarılı.");
                        return(RedirectToAction("MiniSliderList"));
                    }
                    else
                    {
                        HttpContext.Session.SetString("warning", "Mini Slider Güncellenirken hata oluştu. Hata kayıt altına alındı.");

                        _errorRepo.CreateEntity(new ErrorLog
                        {
                            Culture       = "tr",
                            ErrorLocation = "Admin MiniSlider UpdateMiniSlider satır2294",
                            ErrorDetail   = $"a:{a}, b:{b}",
                            ErrorUrl      = HttpContext.Request.Path,
                        });
                        return(RedirectToAction("MiniSliderList"));
                    }
                }

                HttpContext.Session.SetString("warning", $"{messages}, Lütfen formu eksiksiz doldurunuz.");
                return(RedirectToAction("MiniSliderList"));
            }
            catch (Exception e)
            {
                _errorRepo.CreateEntity(new ErrorLog
                {
                    ErrorDetail   = e.Message + " " + e.InnerException + " " + messages,
                    ErrorLocation = "MiniSliderController UpdateMiniSlider",
                    ErrorUrl      = HttpContext.Request.Path
                });
                HttpContext.Session.SetString("warning", "MiniSliderList güncelleme işleminde hata oluştu.");
                return(RedirectToAction("MiniSliderList"));
            }
        }