private async Task UploadResumeAsync(IFormFile fileResume, string clientName) { if (fileResume.Length > 0) { try { string fileNam = clientName + "_resume_" + DateTime.Now.ToString("dd/MM/yyyy"); string folderPath = Path.Combine(_hostingEnvironment.WebRootPath, "Resume"); string filePath = Path.Combine(folderPath, fileNam); using (var stream = new FileStream(filePath, FileMode.Create)) { await fileResume.CopyToAsync(stream).ConfigureAwait(false); } } catch (Exception e) { HttpContext.Session.SetString("alert", _localizer["Error occured while uploading resume. Please try again."]); _errorRepo.CreateEntity(new ErrorLog { ErrorDetail = e.ToString(), ErrorLocation = "UploadResumeAsync" }); } } else { HttpContext.Session.SetString("alert", _localizer["File size is 0 KB."]); } }
public JsonResult Register(string email, string name, string password, bool sms, bool mail) { try { var customer = _customerRepo.AnyEntity(x => x.EmailAddress.Equals(email)); if (customer) { string msgTitle = _localizer["Uyarı"]; string rspText = _localizer["Girdiğiniz eposta sistemimizde kayıtlıdır."]; return(Json(new { success = false, title = msgTitle, responseText = rspText })); } else { bool a = _customerRepo.CreateEntity(new Customer { NameSurname = name, EmailAddress = email, Password = password, IsSubscribedToEmail = mail, IsSubscribedToSMS = sms }); if (a) { string msgTitle = _localizer["Başarılı"]; string rspText = _localizer["Kayıt işlemi başarılı... Lütfen bilgilerinizi girerek oturum açınız."]; string url = _localizer["/tr/uye-girisi"]; HttpContext.Session.SetString("registerSuc", _localizer["Kayıt işlemi başarılı... Lütfen bilgilerinizi girerek oturum açınız."]); HttpContext.Session.SetString("newRegisterEmail", email); return(Json(new { success = true, title = msgTitle, responseText = rspText, togo = url })); } else { string msgTitle = _localizer["Hata"]; string rspText = _localizer["Hata oluştu. Kayıt işlemi gerçekleştirilemedi. Lütfen tekrar deneyiniz."]; return(Json(new { success = false, title = msgTitle, responseText = rspText })); } } } catch (System.Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorDetail = e.Message, ErrorLocation = "LoginCheck", ErrorUrl = HttpContext.Request.Path }); string msgTitle = _localizer["Hata"]; string rspText = _localizer["Hata oluştu ve kayıt altına alındı."]; return(Json(new { success = false, title = msgTitle, responseText = rspText })); } }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { if (culture != "tr" && culture != "ru") { culture = "en"; } var miniSlidersDb = _miniSliderRepo.FindEntities(x => !x.IsDeleted && x.Culture.Equals(culture)); var miniSliderDtos = new List <MiniSliderDto>(); ViewBag.culture = culture; foreach (var miniSlider in miniSlidersDb) { miniSliderDtos.Add(_mapper.Map <MiniSliderDto>(miniSlider)); } return(View(miniSliderDtos)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "MiniSliderComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { //satışta ürünü olmayan markaları slider dan ve side bardan sil, ya da bu markaya ait ürün yoktur yazısı eklemek daha kolay olabilir. ViewBag.Title = culture.Equals("tr") ? "Markalar" : culture.Equals("ru") ? "бренды" : "Brands"; var brands = _brandRepo.GetAllBrandsWithFullJoin().Where(x => !x.IsDeleted).ToList(); List <BrandSideBarComponentDto> dtoList = new List <BrandSideBarComponentDto>(); if (culture.Equals("tr")) { foreach (var item in brands.Where(x => x.Products.Count > 0)) { BrandSideBarComponentDto dto = new BrandSideBarComponentDto(); dto.BrandName = item.BrandName; dto.BrandUrl = $"/tr/markalar/{item.BandNameUrl}/sayfa/1"; dtoList.Add(dto); } } else if (culture.Equals("ru")) { foreach (var item in brands.Where(x => x.Products.Count > 0)) { BrandSideBarComponentDto dto = new BrandSideBarComponentDto(); dto.BrandName = item.BrandName; dto.BrandUrl = $"/ru/brands/{item.BandNameUrl}/page/1"; dtoList.Add(dto); } } else { foreach (var item in brands.Where(x => x.Products.Count > 0)) { BrandSideBarComponentDto dto = new BrandSideBarComponentDto(); dto.BrandName = item.BrandName; dto.BrandUrl = $"/en/brands/{item.BandNameUrl}/page/1"; dtoList.Add(dto); } } return(View(dtoList)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "BrandSideBarComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); HttpContext.Session.SetString("alert", _localizer["Hata oluştu ve kayıt altına alındı."]); //_accesor.HttpContext.Response.Redirect("/"); return(null); } }
public IActionResult HttpStatusCodeHandler(int statusCode) { ViewData["Title"] = _localizer["Error"]; ViewBag.Home = _localizer["Home"]; ViewBag.Error = _localizer["Error"]; ViewBag.Title = _localizer["Error"]; ViewBag.Description = _localizer["Error occured. The page you were looking for, couldn't be found. We will handle it. Thanks for your patience..."]; ViewBag.Oops = _localizer["Oops"]; //rgdrg var exceptionDetails = HttpContext.Features.Get <IExceptionHandlerPathFeature>(); if (exceptionDetails != null) { _errorRepo.CreateEntity(new Models.ErrorLog { ErrorLocation = exceptionDetails.Path, ErrorDetail = exceptionDetails.Error.Message ?? "", StatusCode = statusCode }); } else { _errorRepo.CreateEntity(new Models.ErrorLog { StatusCode = statusCode }); } switch (statusCode) { case 404: ViewBag.ErrorMessage = _localizer["The page you were looking for couldn't be found. We will handle it. Thanks for your patience..."]; ViewBag.ErrorCode = statusCode; break; default: ViewBag.ErrorMessage = _localizer["Something went wrong. We will handle it. Thanks for your patience..."]; ViewBag.ErrorCode = statusCode; break; } return(View("NotFound")); }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { var brands = _brandRepo.GetAllBrandsWithFullJoin().Where(x => !x.IsDeleted).ToList(); var brandDtos = new List <BrandsSliderDto>(); foreach (var item in brands /*.Where(x=>x.Products.Count > 0)*/) { BrandsSliderDto dto = new BrandsSliderDto(); dto.BrandName = item.BrandName; dto.PhotoFileName = item.PhotoFileName; dto.BrandNameUrl = item.BrandName.ConvertToFriendlyUrl(); switch (culture) { case "tr": dto.PhotoAltTag = item.PhotoAltTagTR; ViewBag.culture = "tr"; break; case "en": dto.PhotoAltTag = item.PhotoAltTagEN; ViewBag.culture = "en"; break; case "ru": dto.PhotoAltTag = item.PhotoAltTagRU; ViewBag.culture = "ru"; break; default: dto.PhotoAltTag = item.PhotoAltTagEN; ViewBag.culture = "en"; break; } brandDtos.Add(dto); } return(View(brandDtos)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "BrandsSliderComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }
protected bool Save() { try { return(_context.SaveChanges() > 0 ? true : false); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorDetail = e.ToString(), ErrorLocation = "Repository Save method" }); return(false); } }
public JsonResult LoginCheck(string email, string password) { try { var admin = _adminRepo.FindEntities(x => x.EmailAddress.Equals(email) && x.Password.Equals(password)).FirstOrDefault(); if (admin == null) { string msgTitle = "Uyarı"; string rspText = "Kullanıcı bulunamadı. Lütfen eposta ve şifrenizi kontrol ediniz..."; return(Json(new { success = false, title = msgTitle, responseText = rspText })); } else { //if (rember) //{ // SetMyCookie("adminEmail", email); //} //else //{ // RemoveMyCookie("adminEmail"); //} HttpContext.Session.SetString("adminInfo", email); string msgTitle = "Başarılı"; string rspText = "Giriş işlemi başarılı... yönlendiriliyorsunuz..."; return(Json(new { success = true, title = msgTitle, responseText = rspText })); } } catch (System.Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorDetail = e.Message, ErrorLocation = "AccountController AdminLoginCheck", ErrorUrl = HttpContext.Request.Path }); string msgTitle = "Hata"; string rspText = "Hata oluştu ve kayıt altına alındı."; return(Json(new { success = false, title = msgTitle, responseText = rspText })); } }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { if (culture != "tr" && culture != "ru") { culture = "en"; } ViewBag.culture = culture; var adprosDb = _adproRepo.FindEntities(x => !x.IsDeleted && x.Culture.Equals(culture)).ToList(); adprosDb.ShuffleMyList(); var adproDtos = new List <AdProductDto>(); foreach (var adpro in adprosDb.Take(6)) { adproDtos.Add(_mapper.Map <AdProductDto>(adpro)); } return(View(adproDtos)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "AdsProductComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); HttpContext.Session.SetString("alert", _localizer["Hata oluştu ve kayıt altına alındı."]); //_accesor.HttpContext.Response.Redirect("/"); return(null); } }
public IActionResult ProductsByBrand(string BrandNameUrl, int?page) { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { int currentPage = page ?? 1; var brand = _brandRepo.FindEntity(x => x.BrandName.ConvertToFriendlyUrl().Equals(BrandNameUrl)); int productCount = _productRepo.CountEntity(x => x.BrandId == brand.Id); if (productCount == 0) { HttpContext.Session.SetString("alert", _localizer["Bu markaya ait ürün bulunmamaktadır."]); return(LocalRedirect("/")); } ViewBag.brandName = brand.BrandName; ViewBag.brandNameUrl = brand.BrandName.ConvertToFriendlyUrl(); ViewBag.brandId = brand.Id; ViewBag.metaTitle = culture.Equals("tr") ? brand.MasterPageMetaTitleTR : culture.Equals("ru") ? brand.MasterPageMetaTitleRU : brand.MasterPageMetaTitleEN; ViewBag.metaDesc = culture.Equals("tr") ? brand.MasterPageMetaDescriptionTR : culture.Equals("ru") ? brand.MasterPageMetaDescriptionRU : brand.MasterPageMetaDescriptionEN; double division = Convert.ToDouble(productCount) / Convert.ToDouble(30); int lastPage = Convert.ToInt32(Math.Ceiling(division)); ViewBag.currentPage = currentPage; ViewBag.paginationCount = lastPage; if (currentPage > lastPage || currentPage < 0) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "ProductsBySubCategory", Culture = culture, ErrorDetail = $"Gitmek istenilen sayfa numarası hatalı. Hatalı sayfa numarası: {currentPage}", ErrorUrl = HttpContext.Request.Path }); return(LocalRedirect("/Error/500")); } List <ProductDto> proDtos = new List <ProductDto>(); var products = _productRepo.GetProductsWithBrandId(brand.Id).AsQueryable(); var sortVal = HttpContext.Session.GetString("categorySort"); if (sortVal != null) { if (sortVal.Equals("0")) { ViewBag.selectedDefault = "selected"; } else if (sortVal.Equals("1")) { products = culture.Equals("tr") ? products.OrderBy(x => x.NameTR) : culture.Equals("ru") ? products.OrderBy(x => x.NameRU) : products.OrderBy(x => x.NameEN); ViewBag.selectedByProductName = "selected"; } else if (sortVal.Equals("2")) { products = products.OrderBy(x => x.Brand.BrandName); ViewBag.selectedByBrandName = "selected"; } else if (sortVal.Equals("3")) { products = products.OrderByDescending(x => x.CreatedDate); ViewBag.selectedByNew = "selected"; } else if (sortVal.Equals("4")) { products = products.OrderByDescending(x => x.DiscountRate); ViewBag.selectedBySale = "selected"; } } var targetProducts = page == 1 ? products.Take(30) : (page > 1 && page < lastPage) ? products.Skip((currentPage - 1) * 30).Take(30) : page == lastPage?products.Skip((currentPage - 1) * 30).Take(productCount - ((currentPage - 1) * 30)) : null; if (targetProducts == null) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "ProductsByBrand", Culture = culture, ErrorDetail = "targetProducts null döndü", ErrorUrl = HttpContext.Request.Path }); return(LocalRedirect("/Error/500")); } foreach (var item in targetProducts.ToList()) { ProductDto dto = new ProductDto(); dto.MainPhotoFileName = item.MainPhotoFileName; dto.PhotoAltTag = culture.Equals("tr") ? item.PhotoAltTagTR : culture.Equals("ru") ? item.PhotoAltTagRU : item.PhotoAltTagEN; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.Name = culture.Equals("tr") ? item.NameTR : culture.Equals("ru") ? item.NameRU : item.NameEN; dto.Id = item.Id; dto.ProductNameUrl = culture.Equals("tr") ? item.ProductNameUrlTR : culture.Equals("ru") ? item.ProductNameUrlRU : item.ProductNameUrlEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; if (item.SubCategoryId != null && item.MiddleCategoryId != null) { dto.ProductHref = culture.Equals("tr") ? $"/tr/urun-detay/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.SubCategory.SubCategoryNameUrlTR}/{item.NameTR.ConvertToFriendlyUrl()}" : culture.Equals("ru") ? $"/ru/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.MiddleCategory.MiddleCategoryNameUrlRU}/{item.SubCategory.SubCategoryNameUrlRU}/{item.NameEN.ConvertToFriendlyUrl()}" : $"/en/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.NameEN.ConvertToFriendlyUrl()}"; } else if (item.SubCategoryId == null && item.MiddleCategoryId == null) { dto.ProductHref = culture.Equals("tr") ? $"/tr/urun-detay/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.NameTR.ConvertToFriendlyUrl()}" : culture.Equals("ru") ? $"/ru/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.NameEN.ConvertToFriendlyUrl()}" : $"/en/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.NameEN.ConvertToFriendlyUrl()}"; } else { dto.ProductHref = culture.Equals("tr") ? $"/tr/urun-detay/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.NameTR.ConvertToFriendlyUrl()}" : culture.Equals("ru") ? $"/ru/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.MiddleCategory.MiddleCategoryNameUrlRU}/{item.NameEN.ConvertToFriendlyUrl()}" : $"/en/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.NameEN.ConvertToFriendlyUrl()}"; } proDtos.Add(dto); } //pagination numaralandırması List <int> pageNumbers1 = new List <int>(); for (int i = 1; i <= 5; i++) { if (currentPage - i > 0) { pageNumbers1.Add(currentPage - i); } } int listCount = pageNumbers1.Count; for (int i = 0, j = 1; i < 10 - listCount; i++) { if (currentPage + i <= lastPage) { pageNumbers1.Add(currentPage + i); } } pageNumbers1.Sort(); ViewBag.numbers = pageNumbers1; return(View(proDtos)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "ProductsByBrand", Culture = culture, ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path }); HttpContext.Session.SetString("alert", _localizer["Hata oluştu ve kayıt altına alındı."]); return(LocalRedirect("/")); } }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { var topCatesDb = _topCategoryRepo.GetAllTopCates().ToList(); var topCateDtos = new List <TopCategoryComponentDto>(); ViewBag.culture = culture; switch (culture) { case "tr": foreach (var topCate in topCatesDb.OrderBy(x => x.NameTR)) { TopCategoryComponentDto topDto = new TopCategoryComponentDto(); topDto.Id = topCate.Id; topDto.Name = topCate.NameTR; topDto.HeadDescription = topCate.HeadDescriptionTR; topDto.HeadTitle = topCate.HeadTitleTR; topDto.TopCategoryNameUrl = topCate.TopCategoryNameUrlTR; if (topCate.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var middleCate in topCate.MiddleCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameTR)) { MiddleCategoryComponentDto middleDto = new MiddleCategoryComponentDto(); middleDto.Id = middleCate.Id; middleDto.Name = middleCate.NameTR; middleDto.HeadDescription = middleCate.HeadDescriptionTR; middleDto.HeadTitle = middleCate.HeadTitleTR; middleDto.TopCategoryId = topCate.Id; middleDto.MiddleCategoryNameUrl = middleCate.MiddleCategoryNameUrlTR; if (middleCate.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in middleCate.SubCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameTR)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameTR; subDto.HeadDescription = subCate.HeadDescriptionTR; subDto.HeadTitle = subCate.HeadTitleTR; subDto.MiddleCategoryId = middleCate.Id; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlTR; middleDto.SubCategoryComponentDtos.Add(subDto); } } topDto.MiddleCategoryComponentDtos.Add(middleDto); } } topCateDtos.Add(topDto); } break; case "en": foreach (var topCate in topCatesDb.OrderBy(x => x.NameEN)) { TopCategoryComponentDto topDto = new TopCategoryComponentDto(); topDto.Id = topCate.Id; topDto.Name = topCate.NameEN; topDto.HeadDescription = topCate.HeadDescriptionEN; topDto.HeadTitle = topCate.HeadTitleEN; topDto.TopCategoryNameUrl = topCate.TopCategoryNameUrlEN; if (topCate.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var middleCate in topCate.MiddleCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameEN)) { MiddleCategoryComponentDto middleDto = new MiddleCategoryComponentDto(); middleDto.Id = middleCate.Id; middleDto.Name = middleCate.NameEN; middleDto.HeadDescription = middleCate.HeadDescriptionEN; middleDto.HeadTitle = middleCate.HeadTitleEN; middleDto.TopCategoryId = topCate.Id; middleDto.MiddleCategoryNameUrl = middleCate.MiddleCategoryNameUrlEN; if (middleCate.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in middleCate.SubCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameEN)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameEN; subDto.HeadDescription = subCate.HeadDescriptionEN; subDto.HeadTitle = subCate.HeadTitleEN; subDto.MiddleCategoryId = middleCate.Id; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlEN; middleDto.SubCategoryComponentDtos.Add(subDto); } } topDto.MiddleCategoryComponentDtos.Add(middleDto); } } topCateDtos.Add(topDto); } break; case "ru": foreach (var topCate in topCatesDb.OrderBy(x => x.NameRU)) { TopCategoryComponentDto topDto = new TopCategoryComponentDto(); topDto.Id = topCate.Id; topDto.Name = topCate.NameRU; topDto.HeadDescription = topCate.HeadDescriptionRU; topDto.HeadTitle = topCate.HeadTitleRU; topDto.TopCategoryNameUrl = topCate.TopCategoryNameUrlRU; if (topCate.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var middleCate in topCate.MiddleCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameRU)) { MiddleCategoryComponentDto middleDto = new MiddleCategoryComponentDto(); middleDto.Id = middleCate.Id; middleDto.Name = middleCate.NameRU; middleDto.HeadDescription = middleCate.HeadDescriptionRU; middleDto.HeadTitle = middleCate.HeadTitleRU; middleDto.TopCategoryId = topCate.Id; middleDto.MiddleCategoryNameUrl = middleCate.MiddleCategoryNameUrlRU; if (middleCate.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in middleCate.SubCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameRU)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameRU; subDto.HeadDescription = subCate.HeadDescriptionRU; subDto.HeadTitle = subCate.HeadTitleRU; subDto.MiddleCategoryId = middleCate.Id; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlRU; middleDto.SubCategoryComponentDtos.Add(subDto); } } topDto.MiddleCategoryComponentDtos.Add(middleDto); } } topCateDtos.Add(topDto); } break; default: foreach (var topCate in topCatesDb.OrderBy(x => x.NameEN)) { TopCategoryComponentDto topDto = new TopCategoryComponentDto(); topDto.Id = topCate.Id; topDto.Name = topCate.NameEN; topDto.HeadDescription = topCate.HeadDescriptionEN; topDto.HeadTitle = topCate.HeadTitleEN; topDto.TopCategoryNameUrl = topCate.TopCategoryNameUrlEN; if (topCate.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var middleCate in topCate.MiddleCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameEN)) { MiddleCategoryComponentDto middleDto = new MiddleCategoryComponentDto(); middleDto.Id = middleCate.Id; middleDto.Name = middleCate.NameEN; middleDto.HeadDescription = middleCate.HeadDescriptionEN; middleDto.HeadTitle = middleCate.HeadTitleEN; middleDto.TopCategoryId = topCate.Id; middleDto.MiddleCategoryNameUrl = middleCate.MiddleCategoryNameUrlEN; if (middleCate.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in middleCate.SubCategories.Where(x => !x.IsDeleted).OrderBy(x => x.NameEN)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameEN; subDto.HeadDescription = subCate.HeadDescriptionEN; subDto.HeadTitle = subCate.HeadTitleEN; subDto.MiddleCategoryId = middleCate.Id; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlEN; middleDto.SubCategoryComponentDtos.Add(subDto); } } topDto.MiddleCategoryComponentDtos.Add(middleDto); } } topCateDtos.Add(topDto); } break; } return(View(topCateDtos)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "CategoryNavbarComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { //var topcatesRU = _topRepo.FindEntities(x => !x.IsDeleted).Select(x => x.NameRU); var topcateDtos = new List <FooterTopCategoryDto>(); switch (culture) { case "tr": ViewBag.baslik = "KATEGORİLER"; foreach (var item in _topRepo.FindEntities(x => !x.IsDeleted).Select(x => x.NameTR)) { topcateDtos.Add(new FooterTopCategoryDto { Name = item, TargetHref = $"/tr/kategoriler/{item.ConvertToFriendlyUrl()}/sayfa/1" }); } break; case "en": ViewBag.baslik = "CATEGORIES"; foreach (var item in _topRepo.FindEntities(x => !x.IsDeleted).Select(x => x.NameEN)) { topcateDtos.Add(new FooterTopCategoryDto { Name = item, TargetHref = $"/en/categories/{item.ConvertToFriendlyUrl()}/page/1" }); } break; case "ru": ViewBag.baslik = "КАТЕГОРИИ"; var ruscates = _topRepo.FindEntities(x => !x.IsDeleted).Select(x => new { x.NameRU, x.NameEN }).ToList(); foreach (var item in ruscates) { topcateDtos.Add(new FooterTopCategoryDto { Name = item.NameRU, TargetHref = $"/ru/categories/{item.NameEN.ConvertToFriendlyUrl()}/page/1" }); } break; default: ViewBag.baslik = "CATEGORIES"; foreach (var item in _topRepo.FindEntities(x => !x.IsDeleted).Select(x => x.NameEN)) { topcateDtos.Add(new FooterTopCategoryDto { Name = item, TargetHref = $"/en/categories/{item.ConvertToFriendlyUrl()}/page/1" }); } break; } return(View(topcateDtos)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "FooterTopCategoriesComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { var pros = _productRepo.GetProForSliders(ProductOfferType.ShowcaseProduct).ToList(); pros.ShuffleMyList(); var pro = pros.Take(10); var dtoList = new List <ShowcaseProductsDto>(); var photoDtoList = new List <ProductPhotoDto>(); switch (culture) { case "tr": ViewBag.title = "Vitrin Ürünleri"; ViewBag.newBadge = "Yeni"; ViewBag.freeShipping = "Ücretsiz Kargo"; foreach (var item in pro) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameTR; dto.ProductDescription = item.ProductDescriptionTR; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlTR; dto.PhotoAltTag = item.PhotoAltTagTR; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.ProductNameUrlTR}" : item.SubCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.ProductNameUrlTR}" : $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.SubCategory.SubCategoryNameUrlTR}/{item.ProductNameUrlTR}"; dto.BrandHref = $"/tr/markalar/{dto.BrandNameUrl}"; dtoList.Add(dto); } break; case "en": ViewBag.title = "Showcase Products"; ViewBag.newBadge = "New"; ViewBag.freeShipping = "Free Shipping"; foreach (var item in pro) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; dtoList.Add(dto); } break; case "ru": ViewBag.title = "витрина продуктов"; ViewBag.newBadge = "новый"; ViewBag.freeShipping = "бесплатная доставка"; foreach (var item in pro) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameRU; dto.ProductDescription = item.ProductDescriptionRU; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlRU; dto.PhotoAltTag = item.PhotoAltTagRU; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.ProductNameUrlRU}" : item.SubCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.MiddleCategory.MiddleCategoryNameUrlRU}/{item.ProductNameUrlRU}" : $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.MiddleCategory.MiddleCategoryNameUrlRU}/{item.SubCategory.SubCategoryNameUrlRU}/{item.ProductNameUrlRU}"; dto.BrandHref = $"/ru/brands/{dto.BrandNameUrl}"; dtoList.Add(dto); } break; default: ViewBag.title = "Showcase Products"; ViewBag.newBadge = "New"; ViewBag.freeShipping = "Free Shipping"; foreach (var item in pro) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; dtoList.Add(dto); } break; } return(View(dtoList)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "ShowcaseProductsComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }
public IActionResult CreateBrand(AdminCreateBrandDto 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.BrandPhoto != null) { FileInfo fs = new FileInfo(dto.BrandPhoto.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("BrandList")); } } dto.IsActive = true; dto.BandNameUrl = dto.BrandName.ConvertToFriendlyUrl(); dto.PhotoAltTagTR = dto.BrandName + " Marka Logosu"; dto.PhotoAltTagEN = dto.BrandName + " Brand Logo"; dto.PhotoAltTagRU = dto.BrandName + " Логотип бренда"; dto.MasterPageMetaTitleTR = dto.BrandName + " Markasına ait tüm ürünler premiummedikal.com web sitesinde satılmaktadır."; dto.MasterPageMetaTitleEN = "All " + dto.BrandName + " Brand products are sold on premiummedikal.com website."; dto.MasterPageMetaTitleRU = "Продукты бренда " + dto.BrandName + " продаются на сайте premiummedikal.com"; dto.MasterPageMetaDescriptionTR = dto.BrandName + " markasına ait tüm medikal ürünleri %50'ye varan indirim oranlarıyla iki yıl üretici garantisi altında güvenle satın alabilirsiniz."; dto.MasterPageMetaDescriptionEN = $"You can safely purchase all medical products of the {dto.BrandName} brand with a discount rate of up to 50% under the manufacturer's warranty for two years."; dto.MasterPageMetaDescriptionRU = $"Вы можете смело приобретать все лекарственные препараты марки { dto.BrandName} со скидкой до 50 % по гарантии производителя на два года."; var brandDb = _mapper.Map <Brand>(dto); bool a = _brandRepo.CreateEntity(brandDb); bool b = true; if (dto.BrandPhoto != null) { b = ProcessBrandPhoto(dto.BrandPhoto, brandDb.Id); } if (a && b) { HttpContext.Session.SetString("success", " Marka oluşturma işlemi başarılı."); return(RedirectToAction("BrandList")); } else { HttpContext.Session.SetString("warning", " Marka oluşturulurken hata oluştu. Hata kayıt altına alındı."); _errorRepo.CreateEntity(new ErrorLog { Culture = "tr", ErrorLocation = "Admin Brand CreateBrand satır 144", ErrorDetail = $"a:{a}, b:{b}", ErrorUrl = HttpContext.Request.Path, }); return(RedirectToAction("BrandList")); } } HttpContext.Session.SetString("warning", $"{messages}, Lütfen formu eksiksiz doldurunuz."); return(RedirectToAction("BrandList")); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorDetail = e.Message + " " + e.InnerException + " " + messages, ErrorLocation = "BrandController CreateBrandPost", ErrorUrl = HttpContext.Request.Path }); return(RedirectToAction("BrandList")); } }
public IActionResult CreateCategory(AdminCateDto 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 { dto.Id = 0; dto.HeadDescriptionTR = $"{dto.NameTR} kategorisinde %50'ye varan indirimli medikal ürünler, premiummedikal.com"; dto.HeadDescriptionEN = $"Up to 50% discounted medical products in the {dto.NameEN} category, premiummedikal.com"; dto.HeadDescriptionRU = $"Медицинские изделия со скидкой до 50% в категории {dto.NameRU}, premiummedikal.com"; dto.HeadTitleTR = dto.NameTR; dto.HeadTitleEN = dto.NameEN; dto.HeadTitleRU = dto.NameRU; if (dto.CategoryType == CategoryType.top) { if (_topRepo.AnyEntity(x => x.NameTR.Equals(dto.NameTR)) || _topRepo.AnyEntity(x => x.NameTR.Equals(dto.NameEN)) || _topRepo.AnyEntity(x => x.NameRU.Equals(dto.NameRU))) { HttpContext.Session.SetString("warning", "Eklenmek istenen ana kategorinin Türkçe, İngilizce veya Rusça adı kullanımdadır. Lütfen ana kategori isimlerinin unique olmasına dikkat ediniz."); return(RedirectToAction("CategoryList")); } var cateDb = _mapper.Map <TopCategory>(dto); bool a = _topRepo.CreateEntity(cateDb); cateDb.TopCategoryNameUrlTR = cateDb.NameTR.ConvertToFriendlyUrl(); cateDb.TopCategoryNameUrlEN = cateDb.NameEN.ConvertToFriendlyUrl(); cateDb.TopCategoryNameUrlRU = cateDb.NameEN.ConvertToFriendlyUrl(); bool b = _topRepo.UpdateEntity(cateDb); if (a && b) { HttpContext.Session.SetString("success", "Kategori ekleme işlemi başarılı."); return(RedirectToAction("CategoryList")); } } if (dto.CategoryType == CategoryType.mid) { if (_midRepo.AnyEntity(x => x.NameTR.Equals(dto.NameTR) && x.TopCategoryId == dto.TopCategoryId) || _midRepo.AnyEntity(x => x.NameEN.Equals(dto.NameEN) && x.TopCategoryId == dto.TopCategoryId) || _midRepo.AnyEntity(x => x.NameRU.Equals(dto.NameRU) && x.TopCategoryId == dto.TopCategoryId)) { HttpContext.Session.SetString("warning", "Eklenmek istenen orta kategorinin Türkçe, İngilizce veya Rusça adı kullanımdadır. Lütfen orta kategori isimlerinin unique olmasına dikkat ediniz."); return(RedirectToAction("CategoryList")); } var cateDb = _mapper.Map <MiddleCategory>(dto); bool a = _midRepo.CreateEntity(cateDb); cateDb.MiddleCategoryNameUrlTR = cateDb.NameTR.ConvertToFriendlyUrl(); cateDb.MiddleCategoryNameUrlEN = cateDb.NameEN.ConvertToFriendlyUrl(); cateDb.MiddleCategoryNameUrlRU = cateDb.NameEN.ConvertToFriendlyUrl(); bool b = _midRepo.UpdateEntity(cateDb); if (a && b) { HttpContext.Session.SetString("success", "Kategori ekleme işlemi başarılı."); return(RedirectToAction("CategoryList")); } } if (dto.CategoryType == CategoryType.sub) { if (_subRepo.AnyEntity(x => x.NameTR.Equals(dto.NameTR) && x.MiddleCategoryId == dto.MiddleCategoryId) || _subRepo.AnyEntity(x => x.NameEN.Equals(dto.NameEN) && x.MiddleCategoryId == dto.MiddleCategoryId) || _subRepo.AnyEntity(x => x.NameRU.Equals(dto.NameRU) && x.MiddleCategoryId == dto.MiddleCategoryId)) { HttpContext.Session.SetString("warning", "Eklenmek istenen alt kategorinin Türkçe, İngilizce veya Rusça adı kullanımdadır. Lütfen alt kategori isimlerinin unique olmasına dikkat ediniz."); return(RedirectToAction("CategoryList")); } var cateDb = _mapper.Map <SubCategory>(dto); bool a = _subRepo.CreateEntity(cateDb); cateDb.SubCategoryNameUrlTR = cateDb.NameTR.ConvertToFriendlyUrl(); cateDb.SubCategoryNameUrlEN = cateDb.NameEN.ConvertToFriendlyUrl(); cateDb.SubCategoryNameUrlRU = cateDb.NameEN.ConvertToFriendlyUrl(); bool b = _subRepo.UpdateEntity(cateDb); if (a && b) { HttpContext.Session.SetString("success", "Kategori ekleme işlemi başarılı."); return(RedirectToAction("CategoryList")); } } HttpContext.Session.SetString("warning", "Kategori ekleme işleminde hata oluştu."); return(RedirectToAction("CategoryList")); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorDetail = e.Message + " " + e.InnerException + " " + messages, ErrorLocation = "CategoryController CreateCategory", ErrorUrl = HttpContext.Request.Path }); HttpContext.Session.SetString("warning", "Kategori ekleme işleminde hata oluştu."); return(RedirectToAction("CategoryList")); } }
public IActionResult CreateSlider(AdminCreateSliderDto dto) { if (!AuthCheck()) { return(RedirectToAction("Login", "Account", new { area = "Admin" })); } 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("SliderList")); } } if (dto.SliderThumbPhoto != null) { FileInfo fs = new FileInfo(dto.SliderThumbPhoto.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("SliderList")); } } dto.IsActive = true; int typee = (int)dto.SliderTargetType; //Hedef Marka ise if (typee == 2) { dto.TargetTopCategoryId = null; dto.TargetMiddleCategoryId = null; dto.TargetSubCategoryId = null; dto.TargetProductId = null; if (dto.TargetBrandId == null) { HttpContext.Session.SetString("warning", "Lütfen hedef markayı seçiniz."); return(RedirectToAction("SliderList")); } } //Hedef orta kategori ise if (typee == 3) { dto.TargetSubCategoryId = null; dto.TargetBrandId = null; dto.TargetProductId = null; if (dto.TargetTopCategoryId == null || dto.TargetMiddleCategoryId == null) { HttpContext.Session.SetString("warning", "Hedef olarak orta kategoriyi seçtiniz ancak kategorileri boş bıraktınız. Lütfen hedef ana ve orta kategoriyi seçiniz."); return(RedirectToAction("SliderList")); } if (_midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).TopCategoryId != dto.TargetTopCategoryId) { HttpContext.Session.SetString("warning", "Seçtiğiniz kategorilerin birbiriyle ilişkili olması gerekmektedir."); return(RedirectToAction("SliderList")); } } //Hedef ürün ise if (typee == 4) { dto.TargetTopCategoryId = null; dto.TargetMiddleCategoryId = null; dto.TargetSubCategoryId = null; dto.TargetBrandId = null; if (dto.TargetProductName == null) { HttpContext.Session.SetString("warning", "Lütfen hedef ürün adını seçiniz."); return(RedirectToAction("SliderList")); } } //hedef alt kategori ise if (typee == 0) { dto.TargetBrandId = null; dto.TargetProductId = null; if (dto.TargetTopCategoryId == null || dto.TargetMiddleCategoryId == null || dto.TargetSubCategoryId == null) { HttpContext.Session.SetString("warning", "Hedef olarak alt kategoriyi seçtiniz ancak kategorileri boş bıraktınız.Lütfen hedef ana, orta ve alt kategorilerini seçiniz."); return(RedirectToAction("SliderList")); } if (_subRepo.GetSubCateByIdWithJoin((int)dto.TargetSubCategoryId).MiddleCategoryId != dto.TargetMiddleCategoryId || _midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).TopCategoryId != dto.TargetTopCategoryId) { HttpContext.Session.SetString("warning", "Seçtiğiniz kategorilerin birbiriyle ilişkili olması gerekmektedir."); return(RedirectToAction("SliderList")); } } //hedef ana kategori ise if (typee == 1) { dto.TargetMiddleCategoryId = null; dto.TargetSubCategoryId = null; dto.TargetBrandId = null; dto.TargetProductId = null; if (dto.TargetTopCategoryId == null) { HttpContext.Session.SetString("warning", "Lütfen hedef ana kategoriyi seçiniz."); return(RedirectToAction("SliderList")); } } 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 = typee == 2 ? _brandRepo.GetEntityById((int)dto.TargetBrandId).BrandName + " Markasına ait ürünler premiummedikal.com web sitesinde satılmaktadır" : typee == 1 ? _topRepo.GetEntityById((int)dto.TargetTopCategoryId).HeadTitleTR : typee == 3 ? _midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).HeadTitleTR : typee == 0 ? _subRepo.GetEntityById((int)dto.TargetSubCategoryId).HeadTitleTR : _productRepo.GetEntityById((int)dto.TargetProductId).HeadTitleTR; dto.SliderHref = typee == 2 ? $"/{dto.Culture}/{bran}/{_brandRepo.GetEntityById((int)dto.TargetBrandId).BandNameUrl}/{page}/1" : typee == 1 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlTR}/{page}/1" : typee == 3 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlTR}/{_midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).MiddleCategoryNameUrlTR}/{page}/1" : typee == 0 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlTR}/{_midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).MiddleCategoryNameUrlTR}/{_subRepo.GetEntityById((int)dto.TargetSubCategoryId).SubCategoryNameUrlTR}/{page}/1" : $"/{dto.Culture}/{prodeta}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).Brand.BandNameUrl}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).TopCategory.TopCategoryNameUrlTR}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).MiddleCategory?.MiddleCategoryNameUrlTR}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).SubCategory?.SubCategoryNameUrlTR}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).ProductNameUrlTR}"; } else if (dto.Culture.Equals("ru")) { dto.PhotoAltTag = typee == 2 ? "Продукты бренда " + _brandRepo.GetEntityById((int)dto.TargetBrandId).BrandName + " продаются на сайте premiummedikal.com" : typee == 1 ? _topRepo.GetEntityById((int)dto.TargetTopCategoryId).HeadTitleRU : typee == 3 ? _midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).HeadTitleRU : typee == 0 ? _subRepo.GetEntityById((int)dto.TargetSubCategoryId).HeadTitleRU : _productRepo.GetEntityById((int)dto.TargetProductId).HeadTitleRU; dto.SliderHref = typee == 2 ? $"/{dto.Culture}/{bran}/{_brandRepo.GetEntityById((int)dto.TargetBrandId).BandNameUrl}/{page}/1" : typee == 1 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlEN}/{page}/1" : typee == 3 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlEN}/{_midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).MiddleCategoryNameUrlEN}/{page}/1" : typee == 0 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlEN}/{_midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).MiddleCategoryNameUrlEN}/{_subRepo.GetEntityById((int)dto.TargetSubCategoryId).SubCategoryNameUrlEN}/{page}/1" : $"/{dto.Culture}/{prodeta}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).Brand.BandNameUrl}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).TopCategory.TopCategoryNameUrlEN}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).MiddleCategory?.MiddleCategoryNameUrlEN}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).SubCategory?.SubCategoryNameUrlEN}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).ProductNameUrlEN}"; } else { dto.PhotoAltTag = typee == 2 ? _brandRepo.GetEntityById((int)dto.TargetBrandId).BrandName + " Brand products are sold on premiummedikal.com website" : typee == 1 ? _topRepo.GetEntityById((int)dto.TargetTopCategoryId).HeadTitleEN : typee == 3 ? _midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).HeadTitleEN : typee == 0 ? _subRepo.GetEntityById((int)dto.TargetSubCategoryId).HeadTitleEN : _productRepo.GetEntityById((int)dto.TargetProductId).HeadTitleEN; dto.SliderHref = typee == 2 ? $"/{dto.Culture}/{bran}/{_brandRepo.GetEntityById((int)dto.TargetBrandId).BandNameUrl}/{page}/1" : typee == 1 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlEN}/{page}/1" : typee == 3 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlEN}/{_midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).MiddleCategoryNameUrlEN}/{page}/1" : typee == 0 ? $"/{dto.Culture}/{categor}/{_topRepo.GetEntityById((int)dto.TargetTopCategoryId).TopCategoryNameUrlEN}/{_midRepo.GetEntityById((int)dto.TargetMiddleCategoryId).MiddleCategoryNameUrlEN}/{_subRepo.GetEntityById((int)dto.TargetSubCategoryId).SubCategoryNameUrlEN}/{page}/1" : $"/{dto.Culture}/{prodeta}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).Brand.BandNameUrl}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).TopCategory.TopCategoryNameUrlEN}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).MiddleCategory?.MiddleCategoryNameUrlEN}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).SubCategory?.SubCategoryNameUrlEN}/{_productRepo.GetProductWithNameTR(dto.TargetProductName).ProductNameUrlEN}"; } dto.SliderHref = dto.SliderHref.Replace("///", "/", StringComparison.Ordinal); dto.SliderHref = dto.SliderHref.Replace("//", "/", StringComparison.Ordinal); var slidersDb = _mapper.Map <Slider>(dto); bool a = _sliderRepo.CreateEntity(slidersDb); bool b = true; bool c = true; if (dto.SliderPhoto != null) { b = ProcessSliderMainPhoto(dto.SliderPhoto, slidersDb.Id); } if (dto.SliderThumbPhoto != null) { c = ProcessSliderThumbPhoto(dto.SliderThumbPhoto, slidersDb.Id); } if (a && b && c) { HttpContext.Session.SetString("success", " Slider oluşturma işlemi başarılı."); return(RedirectToAction("SliderList")); } else { HttpContext.Session.SetString("warning", " Slider oluşturulurken hata oluştu. Hata kayıt altına alındı."); _errorRepo.CreateEntity(new ErrorLog { Culture = "tr", ErrorLocation = "Admin Slider CreateSlider satır 214", ErrorDetail = $"a:{a}, b:{b}, c:{c}", ErrorUrl = HttpContext.Request.Path, }); return(RedirectToAction("SliderList")); } } string messages = string.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); HttpContext.Session.SetString("warning", $"{messages}, Lütfen formu eksiksiz doldurunuz."); return(RedirectToAction("SliderList")); }
public JsonResult FindSearchItem(string searchText) { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); var browserCult = locale.RequestCulture.UICulture.ToString(); try { if (string.IsNullOrEmpty(searchText) || string.IsNullOrWhiteSpace(searchText)) { return(Json(new { success = false })); } if (browserCult.Equals("tr")) { var product = _productRepo.GetProductWithNameTR(searchText); if (product != null) { string myLink = $"/tr/urun-detay/{product.Brand.BandNameUrl}/{product.TopCategory?.TopCategoryNameUrlTR}/{product.MiddleCategory?.MiddleCategoryNameUrlTR}/{product.SubCategory?.SubCategoryNameUrlTR}/{product.ProductNameUrlTR}"; myLink = myLink.Replace("///", "/", StringComparison.Ordinal); myLink = myLink.Replace("//", "/", StringComparison.Ordinal); return(Json(new { success = true, result = myLink })); } var topCate = _topRepo.GetTopCateByNameTR(searchText); if (topCate != null) { string myLink = $"/tr/kategoriler/{topCate.TopCategoryNameUrlTR}/sayfa/1"; return(Json(new { success = true, result = myLink })); } var midCate = _midRepo.GetMidCateByNameTR(searchText); if (midCate != null) { string myLink = $"/tr/kategoriler/{midCate.TopCategory.TopCategoryNameUrlTR}/{midCate.MiddleCategoryNameUrlTR}/sayfa/1"; return(Json(new { success = true, result = myLink })); } var subCate = _subRepo.GetSubCateByNameTR(searchText); if (subCate != null) { string myLink = $"/tr/kategoriler/{subCate.MiddleCategory.TopCategory.TopCategoryNameUrlTR}/{subCate.MiddleCategory.MiddleCategoryNameUrlTR}/{subCate.SubCategoryNameUrlTR}/sayfa/1"; return(Json(new { success = true, result = myLink })); } var brand = _brandRepo.GetBrandByName(searchText); if (brand != null) { string myLink = $"/tr/markalar/{brand.BandNameUrl}/sayfa/1"; return(Json(new { success = true, result = myLink })); } } if (browserCult.Equals("ru")) { var product = _productRepo.GetProductWithNameRU(searchText); if (product != null) { string myLink = $"/ru/product-detail/{product.Brand.BandNameUrl}/{product.TopCategory?.TopCategoryNameUrlEN}/{product.MiddleCategory?.MiddleCategoryNameUrlEN}/{product.SubCategory?.SubCategoryNameUrlEN}/{product.ProductNameUrlEN}"; myLink = myLink.Replace("///", "/", StringComparison.Ordinal); myLink = myLink.Replace("//", "/", StringComparison.Ordinal); return(Json(new { success = true, result = myLink })); } var topCate = _topRepo.GetTopCateByNameRU(searchText); if (topCate != null) { string myLink = $"/ru/categories/{topCate.TopCategoryNameUrlEN}/page/1"; return(Json(new { success = true, result = myLink })); } var midCate = _midRepo.GetMidCateByNameRU(searchText); if (midCate != null) { string myLink = $"/ru/categories/{midCate.TopCategory.TopCategoryNameUrlEN}/{midCate.MiddleCategoryNameUrlEN}/page/1"; return(Json(new { success = true, result = myLink })); } var subCate = _subRepo.GetSubCateByNameRU(searchText); if (subCate != null) { string myLink = $"/ru/categories/{subCate.MiddleCategory.TopCategory.TopCategoryNameUrlEN}/{subCate.MiddleCategory.MiddleCategoryNameUrlEN}/{subCate.SubCategoryNameUrlEN}/page/1"; return(Json(new { success = true, result = myLink })); } var brand = _brandRepo.GetBrandByName(searchText); if (brand != null) { string myLink = $"/ru/brands/{brand.BandNameUrl}/page/1"; return(Json(new { success = true, result = myLink })); } } else { var product = _productRepo.GetProductWithNameEN(searchText); if (product != null) { string myLink = $"/en/product-detail/{product.Brand.BandNameUrl}/{product.TopCategory?.TopCategoryNameUrlEN}/{product.MiddleCategory?.MiddleCategoryNameUrlEN}/{product.SubCategory?.SubCategoryNameUrlEN}/{product.ProductNameUrlEN}"; myLink = myLink.Replace("///", "/", StringComparison.Ordinal); myLink = myLink.Replace("//", "/", StringComparison.Ordinal); return(Json(new { success = true, result = myLink })); } var topCate = _topRepo.GetTopCateByNameEN(searchText); if (topCate != null) { string myLink = $"/en/categories/{topCate.TopCategoryNameUrlEN}/page/1"; return(Json(new { success = true, result = myLink })); } var midCate = _midRepo.GetMidCateByNameEN(searchText); if (midCate != null) { string myLink = $"/en/categories/{midCate.TopCategory.TopCategoryNameUrlEN}/{midCate.MiddleCategoryNameUrlEN}/page/1"; return(Json(new { success = true, result = myLink })); } var subCate = _subRepo.GetSubCateByNameEN(searchText); if (subCate != null) { string myLink = $"/en/categories/{subCate.MiddleCategory.TopCategory.TopCategoryNameUrlEN}/{subCate.MiddleCategory.MiddleCategoryNameUrlEN}/{subCate.SubCategoryNameUrlEN}/page/1"; return(Json(new { success = true, result = myLink })); } var brand = _brandRepo.GetBrandByName(searchText); if (brand != null) { string myLink = $"/en/brands/{brand.BandNameUrl}/page/1"; return(Json(new { success = true, result = myLink })); } } string mes = browserCult.Equals("tr") ? "Sonuç bulunamadı" : browserCult.Equals("ru") ? "Не было результатов" : "There were no results"; return(Json(new { success = false, message = mes })); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "Home Controller FindSearchItem", Culture = browserCult, ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path }); string mes = browserCult.Equals("tr") ? "Sonuç bulunamadı" : browserCult.Equals("ru") ? "Не было результатов" : "There were no results"; return(Json(new { success = false, message = mes })); } }
public IViewComponentResult Invoke(string categoryType, int id) { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { CategorySidebarDto dto = new CategorySidebarDto(); ViewBag.filter = culture.Equals("tr") ? "Filtre" : culture.Equals("ru") ? "фильтр" : "Filter"; switch (culture) { case "tr": if (categoryType.Equals("top")) { var categoryTop = _topCategoryRepo.GetTopCateById(id); if (categoryTop.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var midCate in categoryTop.MiddleCategories.Where(x => !x.IsDeleted)) { MiddleCategoryComponentDto midDto = new MiddleCategoryComponentDto(); midDto.Id = midCate.Id; midDto.Name = midCate.NameTR; midDto.MiddleCategoryNameUrl = midCate.MiddleCategoryNameUrlTR; midDto.TopCategoryId = midCate.TopCategoryId; midDto.CategoryHref = $"/tr/kategoriler/{midCate.TopCategory.TopCategoryNameUrlTR}/{midCate.MiddleCategoryNameUrlTR}/sayfa/1"; dto.MiddleCategoryComponentDtos.Add(midDto); dto.TopCategoryId = midCate.Id; dto.MiddleCategoryComponentDtos.Add(midDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryTop.NameTR; return(View(dto)); } else if (categoryType.Equals("mid")) { var categoryMid = _middleCategoryRepo.GetMidCateById(id); if (categoryMid.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in categoryMid.SubCategories.Where(x => !x.IsDeleted)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameTR; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlTR; subDto.MiddleCategoryId = subCate.MiddleCategoryId; subDto.CategoryHref = $"/tr/kategoriler/{subCate.MiddleCategory.TopCategory.TopCategoryNameUrlTR}/{subCate.MiddleCategory.MiddleCategoryNameUrlTR}/{subCate.SubCategoryNameUrlTR}/sayfa/1"; dto.SubCategoryComponentDtos.Add(subDto); dto.TopCategoryId = categoryMid.TopCategoryId; dto.SubCategoryComponentDtos.Add(subDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryMid.NameTR; return(View(dto)); } else { var categorySub = _subCategoryRepo.FindEntity(x => !x.IsDeleted && x.Id == id); dto.CategoryType = categoryType; dto.ComponentTitle = categorySub.NameTR; return(View(dto)); } case "en": if (categoryType.Equals("top")) { var categoryTop = _topCategoryRepo.GetTopCateById(id); if (categoryTop.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var midCate in categoryTop.MiddleCategories.Where(x => !x.IsDeleted)) { MiddleCategoryComponentDto midDto = new MiddleCategoryComponentDto(); midDto.Id = midCate.Id; midDto.Name = midCate.NameEN; midDto.MiddleCategoryNameUrl = midCate.MiddleCategoryNameUrlEN; midDto.TopCategoryId = midCate.TopCategoryId; midDto.CategoryHref = $"/en/categories/{midCate.TopCategory.TopCategoryNameUrlEN}/{midCate.MiddleCategoryNameUrlEN}/page/1"; dto.MiddleCategoryComponentDtos.Add(midDto); dto.TopCategoryId = midCate.Id; dto.MiddleCategoryComponentDtos.Add(midDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryTop.NameEN; return(View(dto)); } else if (categoryType.Equals("mid")) { var categoryMid = _middleCategoryRepo.GetMidCateById(id); if (categoryMid.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in categoryMid.SubCategories.Where(x => !x.IsDeleted)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameEN; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlEN; subDto.MiddleCategoryId = subCate.MiddleCategoryId; subDto.CategoryHref = $"/en/categories/{subCate.MiddleCategory.TopCategory.TopCategoryNameUrlEN}/{subCate.MiddleCategory.MiddleCategoryNameUrlEN}/{subCate.SubCategoryNameUrlEN}/page/1"; dto.SubCategoryComponentDtos.Add(subDto); dto.TopCategoryId = categoryMid.TopCategoryId; dto.SubCategoryComponentDtos.Add(subDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryMid.NameEN; return(View(dto)); } else { var categorySub = _subCategoryRepo.FindEntity(x => !x.IsDeleted && x.Id == id); dto.CategoryType = categoryType; dto.ComponentTitle = categorySub.NameEN; return(View(dto)); } case "ru": if (categoryType.Equals("top")) { var categoryTop = _topCategoryRepo.GetTopCateById(id); if (categoryTop.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var midCate in categoryTop.MiddleCategories.Where(x => !x.IsDeleted)) { MiddleCategoryComponentDto midDto = new MiddleCategoryComponentDto(); midDto.Id = midCate.Id; midDto.Name = midCate.NameRU; midDto.MiddleCategoryNameUrl = midCate.MiddleCategoryNameUrlRU; midDto.TopCategoryId = midCate.TopCategoryId; midDto.CategoryHref = $"/ru/categories/{midCate.TopCategory.TopCategoryNameUrlRU}/{midCate.MiddleCategoryNameUrlRU}/page/1"; dto.MiddleCategoryComponentDtos.Add(midDto); dto.TopCategoryId = midCate.Id; dto.MiddleCategoryComponentDtos.Add(midDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryTop.NameRU; return(View(dto)); } else if (categoryType.Equals("mid")) { var categoryMid = _middleCategoryRepo.GetMidCateById(id); if (categoryMid.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in categoryMid.SubCategories.Where(x => !x.IsDeleted)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameRU; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlRU; subDto.MiddleCategoryId = subCate.MiddleCategoryId; subDto.CategoryHref = $"/ru/categories/{subCate.MiddleCategory.TopCategory.TopCategoryNameUrlRU}/{subCate.MiddleCategory.MiddleCategoryNameUrlRU}/{subCate.SubCategoryNameUrlRU}/page/1"; dto.SubCategoryComponentDtos.Add(subDto); dto.TopCategoryId = categoryMid.TopCategoryId; dto.SubCategoryComponentDtos.Add(subDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryMid.NameRU; return(View(dto)); } else { var categorySub = _subCategoryRepo.FindEntity(x => !x.IsDeleted && x.Id == id); dto.CategoryType = categoryType; dto.ComponentTitle = categorySub.NameRU; return(View(dto)); } default: if (categoryType.Equals("top")) { var categoryTop = _topCategoryRepo.GetTopCateById(id); if (categoryTop.MiddleCategories.Any(x => !x.IsDeleted)) { foreach (var midCate in categoryTop.MiddleCategories.Where(x => !x.IsDeleted)) { MiddleCategoryComponentDto midDto = new MiddleCategoryComponentDto(); midDto.Id = midCate.Id; midDto.Name = midCate.NameEN; midDto.MiddleCategoryNameUrl = midCate.MiddleCategoryNameUrlEN; midDto.TopCategoryId = midCate.TopCategoryId; midDto.CategoryHref = $"/en/categories/{midCate.TopCategory.TopCategoryNameUrlEN}/{midCate.MiddleCategoryNameUrlEN}/page/1"; dto.MiddleCategoryComponentDtos.Add(midDto); dto.TopCategoryId = midCate.Id; dto.MiddleCategoryComponentDtos.Add(midDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryTop.NameEN; return(View(dto)); } else if (categoryType.Equals("mid")) { var categoryMid = _middleCategoryRepo.GetMidCateById(id); if (categoryMid.SubCategories.Any(x => !x.IsDeleted)) { foreach (var subCate in categoryMid.SubCategories.Where(x => !x.IsDeleted)) { SubCategoryComponentDto subDto = new SubCategoryComponentDto(); subDto.Id = subCate.Id; subDto.Name = subCate.NameEN; subDto.SubCategoryNameUrl = subCate.SubCategoryNameUrlEN; subDto.MiddleCategoryId = subCate.MiddleCategoryId; subDto.CategoryHref = $"/en/categories/{subCate.MiddleCategory.TopCategory.TopCategoryNameUrlEN}/{subCate.MiddleCategory.MiddleCategoryNameUrlEN}/{subCate.SubCategoryNameUrlEN}/page/1"; dto.SubCategoryComponentDtos.Add(subDto); dto.TopCategoryId = categoryMid.TopCategoryId; dto.SubCategoryComponentDtos.Add(subDto); } } dto.CategoryType = categoryType; dto.ComponentTitle = categoryMid.NameEN; return(View(dto)); } else { var categorySub = _subCategoryRepo.FindEntity(x => !x.IsDeleted && x.Id == id); dto.CategoryType = categoryType; dto.ComponentTitle = categorySub.NameEN; return(View(dto)); } } } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "CategorySidebarComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }
public IActionResult CreateMiniSlider(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("warnng", "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.SliderHref = $"/{dto.Culture}/{prodeta}/{targetProduct.Brand.BandNameUrl}/{targetProduct.TopCategory.TopCategoryNameUrlTR}/{targetProduct.MiddleCategory?.MiddleCategoryNameUrlTR}/{targetProduct.SubCategory?.SubCategoryNameUrlTR}/{targetProduct.ProductNameUrlTR}"; dto.PhotoAltTag = targetProduct.PhotoAltTagTR; } else if (dto.Culture.Equals("ru")) { dto.SliderHref = $"/{dto.Culture}/{prodeta}/{targetProduct.Brand.BandNameUrl}/{targetProduct.TopCategory.TopCategoryNameUrlEN}/{targetProduct.MiddleCategory?.MiddleCategoryNameUrlEN}/{targetProduct.SubCategory?.SubCategoryNameUrlEN}/{targetProduct.ProductNameUrlEN}"; dto.PhotoAltTag = targetProduct.PhotoAltTagRU; } else { dto.SliderHref = $"/{dto.Culture}/{prodeta}/{targetProduct.Brand.BandNameUrl}/{targetProduct.TopCategory.TopCategoryNameUrlEN}/{targetProduct.MiddleCategory?.MiddleCategoryNameUrlEN}/{targetProduct.SubCategory?.SubCategoryNameUrlEN}/{targetProduct.ProductNameUrlEN}"; dto.PhotoAltTag = targetProduct.PhotoAltTagEN; } dto.SliderHref = dto.SliderHref.Replace("///", "/", StringComparison.Ordinal); dto.SliderHref = dto.SliderHref.Replace("//", "/", StringComparison.Ordinal); var miniSliderDb = _mapper.Map <MiniSlider>(dto); bool a = _miniSliderRepo.CreateEntity(miniSliderDb); bool b = true; if (dto.SliderPhoto != null) { b = ProcessMiniSliderPhoto(dto.SliderPhoto, miniSliderDb.Id); } if (a && b) { HttpContext.Session.SetString("success", "Mini Slider oluşturma işlemi başarılı."); return(RedirectToAction("MiniSliderList")); } else { HttpContext.Session.SetString("warning", "Mini Slider oluşturulurken hata oluştu. Hata kayıt altına alındı."); _errorRepo.CreateEntity(new ErrorLog { Culture = "tr", ErrorLocation = "Admin MiniSlider CreateMiniSlider satır 152", 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 CreateMiniSlider", ErrorUrl = HttpContext.Request.Path }); HttpContext.Session.SetString("warning", "MiniSlider ekleme işleminde hata oluştu."); return(RedirectToAction("MiniSliderList")); } }
public IActionResult SingleProduct([FromRoute] string ProductNameUrl) { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); string comingUrl1 = ProductNameUrl; string x = Request.Headers["Referer"]; var url = _httpContextAccessor.HttpContext?.Request?.GetDisplayUrl(); string[] urlParts2 = x.Split("/"); string[] urlParts3 = url.Split("/"); string comingUrl2 = urlParts2[urlParts2.Length - 1]; string comingUrl3 = urlParts3[urlParts3.Length - 1]; string finalProNameUrl = !comingUrl1.Equals("placeholder.gif") ? comingUrl1 : !comingUrl2.Equals("placeholder.gif") ? comingUrl2 : comingUrl3; try { var product = _productRepo.GetProductWithNameUrl(finalProNameUrl, "tr") ?? _productRepo.GetProductWithNameUrl(finalProNameUrl, "en"); if (product == null) { HttpContext.Session.SetString("alert", _localizer["Ürün bulunamadı."]); return(LocalRedirect("/")); } ViewBag.metaTitle = culture.Equals("tr") ? product.HeadTitleTR : culture.Equals("ru") ? product.HeadTitleRU : product.HeadTitleEN; ViewBag.metaDesc = culture.Equals("tr") ? product.HeadDescriptionTR : culture.Equals("ru") ? product.HeadDescriptionRU : product.HeadDescriptionEN; bool favPros = false; if (HttpContext.Session.GetObject <SessionDto>("customerInfo") != null) { var customer = _customerRepo.GetEntityById(HttpContext.Session.GetObject <SessionDto>("customerInfo").Id); favPros = _fpRepo.AnyEntity(x => x.CustomerId == customer.Id && x.ProductId == product.Id); } SingleProductDto dto = new SingleProductDto(); dto.Id = product.Id; dto.Name = culture.Equals("tr") ? product.NameTR : culture.Equals("ru") ? product.NameRU : product.NameEN; dto.ProductDescription = culture.Equals("tr") ? product.ProductDescriptionTR : culture.Equals("ru") ? product.ProductDescriptionRU : product.ProductDescriptionEN; dto.MainPhotoFileName = product.MainPhotoFileName; dto.PhotoAltTag = culture.Equals("tr") ? product.PhotoAltTagTR : culture.Equals("ru") ? product.PhotoAltTagRU : product.PhotoAltTagEN; dto.ProductCode = product.ProductCode; dto.DiscountRate = product.DiscountRate; dto.HasNewBadge = product.HasNewBadge; dto.IsFreeShipping = product.IsFreeShipping; dto.HeadTitle = culture.Equals("tr") ? product.HeadTitleTR : culture.Equals("ru") ? product.HeadTitleRU : product.HeadTitleEN; dto.HeadDescription = culture.Equals("tr") ? product.HeadDescriptionTR : culture.Equals("ru") ? product.HeadDescriptionRU : product.HeadDescriptionEN; dto.BrandName = product.Brand.BrandName; dto.TopCategoryName = culture.Equals("tr") ? product.TopCategory.NameTR : culture.Equals("ru") ? product.TopCategory.NameRU : product.TopCategory.NameEN; dto.TopCategoryNameUrl = culture.Equals("tr") ? product.TopCategory.TopCategoryNameUrlTR : product.TopCategory.TopCategoryNameUrlEN; dto.MiddleCategoryName = culture.Equals("tr") ? product.MiddleCategory?.NameTR : culture.Equals("ru") ? product.MiddleCategory?.NameRU : product.MiddleCategory?.NameEN; dto.MiddleCategoryNameUrl = culture.Equals("tr") ? product.MiddleCategory?.MiddleCategoryNameUrlTR : product.MiddleCategory?.MiddleCategoryNameUrlEN; dto.SubCategoryName = culture.Equals("tr") ? product.SubCategory?.NameTR : culture.Equals("ru") ? product.SubCategory?.NameRU : product.SubCategory?.NameEN; dto.SubCategoryNameUrl = culture.Equals("tr") ? product.SubCategory?.SubCategoryNameUrlTR : product.SubCategory?.SubCategoryNameUrlEN; dto.ProductOfferType = product.ProductOfferType; dto.IsFavorite = favPros; dto.PhotoAltTag = culture.Equals("tr") ? product.PhotoAltTagTR : culture.Equals("ru") ? product.PhotoAltTagRU : product.PhotoAltTagEN; foreach (var item in product.ProductPhotos.Where(x => !x.IsMainPhoto)) { SingleProductPhotoDto photoDto = new SingleProductPhotoDto(); photoDto.Id = item.Id; photoDto.PhotoFileName = item.PhotoFileName; dto.ProductPhotoDtos.Add(photoDto); } return(View(dto)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "SingleProduct", ErrorDetail = e.Message + " , " + e.InnerException + $"comingUrl1:{comingUrl1}, comingUrl2:{comingUrl2}, comingUrl3:{comingUrl3}, finalProNameUrl:{finalProNameUrl}", ErrorUrl = HttpContext.Request.Path }); HttpContext.Session.SetString("alert", _localizer["Hata oluştu ve kayıt altına alındı."]); return(LocalRedirect("/")); } }
public IViewComponentResult Invoke(int proId) { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { ViewBag.Title = culture.Equals("tr") ? "Benzer Ürünler" : culture.Equals("ru") ? "подобная продукция" : "Sımılar Products"; ViewBag.newBadge = culture.Equals("tr") ? "Yeni" : culture.Equals("ru") ? "Новый" : "New"; ViewBag.freeShipping = culture.Equals("tr") ? "Ücretsiz Kargo" : culture.Equals("ru") ? "бесплатная доставка" : "Free Shipping"; var proDb = _proRepo.GetProductWithId(proId); List <Product> productsDb = new List <Product>(); List <SmilarProductDto> dtoList = new List <SmilarProductDto>(); if (proDb.SubCategoryId != null) { var simprosWithSameSubcate = _proRepo.GetProductsWithSubcateId((int)proDb.SubCategoryId).ToList(); simprosWithSameSubcate.Remove(proDb); simprosWithSameSubcate.ShuffleMyList(); productsDb.AddRange(simprosWithSameSubcate.Take(10)); } if (proDb.MiddleCategoryId != null && productsDb.Count < 10) { var simprosWithSameMidcate = _proRepo.GetProductsWithMidcateId((int)proDb.MiddleCategoryId).ToList(); simprosWithSameMidcate.Remove(proDb); simprosWithSameMidcate.ShuffleMyList(); productsDb.AddRange(simprosWithSameMidcate.Take(10 - productsDb.Count)); } if (productsDb.Count < 10) { var simprosWithSameTopcate = _proRepo.GetProductsWithTopcateId(proDb.TopCategoryId).ToList(); simprosWithSameTopcate.Remove(proDb); simprosWithSameTopcate.ShuffleMyList(); productsDb.AddRange(simprosWithSameTopcate.Take(10 - productsDb.Count)); } productsDb.ShuffleMyList(); var myDistinctList = productsDb.GroupBy(i => i.Id) .Select(g => g.First()).ToList(); if (culture.Equals("tr")) { foreach (var item in myDistinctList) { SmilarProductDto dto = new SmilarProductDto(); dto.MainPhotoFileName = item.MainPhotoFileName; dto.PhotoAltTag = item.PhotoAltTagTR; dto.HasNewBadge = item.HasNewBadge; dto.Name = item.NameTR; dto.SingleProductHref = item.MiddleCategory == null ? $"/tr/urun-detay/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.ProductNameUrlTR}" : item.SubCategory == null ? $"/tr/urun-detay/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.ProductNameUrlTR}" : $"/tr/urun-detay/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.SubCategory.SubCategoryNameUrlTR}/{item.ProductNameUrlTR}"; dtoList.Add(dto); } } else if (culture.Equals("ru")) { foreach (var item in myDistinctList) { SmilarProductDto dto = new SmilarProductDto(); dto.MainPhotoFileName = item.MainPhotoFileName; dto.PhotoAltTag = item.PhotoAltTagRU; dto.HasNewBadge = item.HasNewBadge; dto.Name = item.NameRU; dto.SingleProductHref = item.MiddleCategory == null ? $"/ru/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.ProductNameUrlRU}" : item.SubCategory == null ? $"/ru/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.MiddleCategory.MiddleCategoryNameUrlRU}/{item.ProductNameUrlRU}" : $"/ru/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlRU}/{item.MiddleCategory.MiddleCategoryNameUrlRU}/{item.SubCategory.SubCategoryNameUrlRU}/{item.ProductNameUrlRU}"; dtoList.Add(dto); } } else { foreach (var item in myDistinctList) { SmilarProductDto dto = new SmilarProductDto(); dto.MainPhotoFileName = item.MainPhotoFileName; dto.PhotoAltTag = item.PhotoAltTagEN; dto.HasNewBadge = item.HasNewBadge; dto.Name = item.NameEN; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{item.Brand.BandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dtoList.Add(dto); } } return(View(dtoList)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "SimilarProductsComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }
public IViewComponentResult Invoke() { var locale = Request.HttpContext.Features.Get <IRequestCultureFeature>(); string culture = locale.RequestCulture.UICulture.ToString(); try { var proTabsDto = new ProductTabsDto(); var campaignProducts = _productRepo.GetProForSliders(ProductOfferType.CampaignProduct).ToList(); var onSaleProducts = _productRepo.GetProForSliders(ProductOfferType.OnSaleProduct).ToList(); var weeklyDealProducts = _productRepo.GetProForSliders(ProductOfferType.WeeklyDealProduct).ToList(); var newProducts = _productRepo.GetProForSliders(ProductOfferType.NewProduct).OrderByDescending(x => x.CreatedDate).OrderByDescending(x => x.UpdatedDate).ToList(); campaignProducts.ShuffleMyList(); onSaleProducts.ShuffleMyList(); weeklyDealProducts.ShuffleMyList(); newProducts.ShuffleMyList(); ViewBag.cul = culture; switch (culture) { case "tr": proTabsDto.CampaignProductsTitle = "KAMPANYALI ÜRÜNLER"; proTabsDto.OnSaleProductsTitle = "İNDİRİMDEKİLER"; proTabsDto.WeeklyDealProductsTitle = "HAFTANIN ÜRÜNLERİ"; proTabsDto.NewProductsTitle = "YENİ ÜRÜNLER"; proTabsDto.FreeShippingText = "Ücretsiz Kargo"; proTabsDto.NewBadgeText = "Yeni"; foreach (var item in campaignProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameTR; dto.ProductDescription = item.ProductDescriptionTR; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlTR; dto.PhotoAltTag = item.PhotoAltTagTR; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.ProductNameUrlTR}" : item.SubCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.ProductNameUrlTR}" : $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.SubCategory.SubCategoryNameUrlTR}/{item.ProductNameUrlTR}"; dto.BrandHref = $"/tr/markalar/{dto.BrandNameUrl}"; proTabsDto.CampaignProducts.Add(dto); } foreach (var item in onSaleProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameTR; dto.ProductDescription = item.ProductDescriptionTR; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlTR; dto.PhotoAltTag = item.PhotoAltTagTR; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.ProductNameUrlTR}" : item.SubCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.ProductNameUrlTR}" : $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.SubCategory.SubCategoryNameUrlTR}/{item.ProductNameUrlTR}"; dto.BrandHref = $"/tr/markalar/{dto.BrandNameUrl}"; proTabsDto.OnSaleProducts.Add(dto); } foreach (var item in weeklyDealProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameTR; dto.ProductDescription = item.ProductDescriptionTR; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlTR; dto.PhotoAltTag = item.PhotoAltTagTR; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.ProductNameUrlTR}" : item.SubCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.ProductNameUrlTR}" : $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.SubCategory.SubCategoryNameUrlTR}/{item.ProductNameUrlTR}"; dto.BrandHref = $"/tr/markalar/{dto.BrandNameUrl}"; proTabsDto.WeeklyDealProducts.Add(dto); } foreach (var item in newProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameTR; dto.ProductDescription = item.ProductDescriptionTR; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlTR; dto.PhotoAltTag = item.PhotoAltTagTR; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.ProductNameUrlTR}" : item.SubCategory == null ? $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.ProductNameUrlTR}" : $"/tr/urun-detay/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlTR}/{item.MiddleCategory.MiddleCategoryNameUrlTR}/{item.SubCategory.SubCategoryNameUrlTR}/{item.ProductNameUrlTR}"; dto.BrandHref = $"/tr/markalar/{dto.BrandNameUrl}"; proTabsDto.NewProducts.Add(dto); } break; case "en": proTabsDto.CampaignProductsTitle = "CAMPAIGN PRODUCTS"; proTabsDto.OnSaleProductsTitle = "DISCOUNTED"; proTabsDto.WeeklyDealProductsTitle = "PRODUCTS OF THE WEEK"; proTabsDto.NewProductsTitle = "NEW PRODUCTS"; proTabsDto.FreeShippingText = "Free Shipping"; proTabsDto.NewBadgeText = "New"; foreach (var item in campaignProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.CampaignProducts.Add(dto); } foreach (var item in onSaleProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.OnSaleProducts.Add(dto); } foreach (var item in weeklyDealProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.WeeklyDealProducts.Add(dto); } foreach (var item in newProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.NewProducts.Add(dto); } break; case "ru": proTabsDto.CampaignProductsTitle = "АГИТАЦИОННУЮ ПРОДУКЦИЮ"; proTabsDto.OnSaleProductsTitle = "ДИСКОНТИРОВАННЫЙ"; proTabsDto.WeeklyDealProductsTitle = "ПРОДУКТЫ НЕДЕЛИ"; proTabsDto.NewProductsTitle = "НОВЫЕ ПРОДУКТЫ"; proTabsDto.FreeShippingText = "бесплатная доставка"; proTabsDto.NewBadgeText = "новый"; foreach (var item in campaignProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameRU; dto.ProductDescription = item.ProductDescriptionRU; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlRU; dto.PhotoAltTag = item.PhotoAltTagRU; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/ru/brands/{dto.BrandNameUrl}"; proTabsDto.CampaignProducts.Add(dto); } foreach (var item in onSaleProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameRU; dto.ProductDescription = item.ProductDescriptionRU; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlRU; dto.PhotoAltTag = item.PhotoAltTagRU; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/ru/brands/{dto.BrandNameUrl}"; proTabsDto.OnSaleProducts.Add(dto); } foreach (var item in weeklyDealProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameRU; dto.ProductDescription = item.ProductDescriptionRU; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlRU; dto.PhotoAltTag = item.PhotoAltTagRU; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/ru/brands/{dto.BrandNameUrl}"; proTabsDto.WeeklyDealProducts.Add(dto); } foreach (var item in newProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameRU; dto.ProductDescription = item.ProductDescriptionRU; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlRU; dto.PhotoAltTag = item.PhotoAltTagRU; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/ru/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/ru/brands/{dto.BrandNameUrl}"; proTabsDto.NewProducts.Add(dto); } break; default: proTabsDto.CampaignProductsTitle = "CAMPAIGN PRODUCTS"; proTabsDto.OnSaleProductsTitle = "DISCOUNTED"; proTabsDto.WeeklyDealProductsTitle = "PRODUCTS OF THE WEEK"; proTabsDto.NewProductsTitle = "NEW PRODUCTS"; proTabsDto.FreeShippingText = "Free Shipping"; proTabsDto.NewBadgeText = "New"; foreach (var item in campaignProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.CampaignProducts.Add(dto); } foreach (var item in onSaleProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.OnSaleProducts.Add(dto); } foreach (var item in weeklyDealProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.WeeklyDealProducts.Add(dto); } foreach (var item in newProducts.Take(8)) { ShowcaseProductsDto dto = new ShowcaseProductsDto(); dto.Id = item.Id; dto.Name = item.NameEN; dto.ProductDescription = item.ProductDescriptionEN; dto.MainPhotoFileName = item.MainPhotoFileName; dto.ProductNameUrl = item.ProductNameUrlEN; dto.PhotoAltTag = item.PhotoAltTagEN; dto.BrandName = item.Brand.BrandName; dto.BrandNameUrl = item.Brand.BandNameUrl; dto.HasNewBadge = item.HasNewBadge; dto.IsFreeShipping = item.IsFreeShipping; dto.SingleProductHref = item.MiddleCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.ProductNameUrlEN}" : item.SubCategory == null ? $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.ProductNameUrlEN}" : $"/en/product-detail/{dto.BrandNameUrl}/{item.TopCategory.TopCategoryNameUrlEN}/{item.MiddleCategory.MiddleCategoryNameUrlEN}/{item.SubCategory.SubCategoryNameUrlEN}/{item.ProductNameUrlEN}"; dto.BrandHref = $"/en/brands/{dto.BrandNameUrl}"; proTabsDto.NewProducts.Add(dto); } break; } return(View(proTabsDto)); } catch (Exception e) { _errorRepo.CreateEntity(new ErrorLog { ErrorLocation = "ProductTabsComponent", ErrorDetail = e.Message + " , " + e.InnerException, ErrorUrl = HttpContext.Request.Path, Culture = culture }); return(null); } }