public IActionResult Product(string url) { int id = 0; var sectionUrls = url.Split("-"[0]); if (sectionUrls.Any()) { int.TryParse(sectionUrls[0], out id); } if (id == 0) { return(NotFound()); } Navigation navigation = commonRepository.GetNavigation(); SeoData seo = commonRepository.GetSeo("product"); Product product = productsRepository.GetProduct(id); List <Breadcrumb> breadcrumbs = new List <Breadcrumb>() { new Breadcrumb("Главная", "/"), new Breadcrumb("Каталог", "/catalog"), new Breadcrumb(product.Title, $"/products/{product.TitleUrl}") }; var productPage = new ProductPage(seo, navigation, breadcrumbs, product); return(View(productPage)); }
/// <summary> /// Возвращает SEO-данные для страницы.. /// </summary> public SeoData GetSeo(string key) { SeoData seo = new SeoData(); switch (key) { case "main": seo.Title = "MyTotto - Онлайн-магазин косметики"; seo.Description = "Интернет-магазин корейской косметики"; seo.Keywords = "Купить косметику корейскую"; break; case "catalog": seo.Title = "Каталог - MyTotto - Онлайн-магазин косметики"; seo.Description = "Интернет-магазин корейской косметики"; seo.Keywords = "Купить косметику корейскую"; break; case "product": seo.Title = "Продукт - MyTotto - Онлайн-магазин косметики"; seo.Description = "Интернет-магазин корейской косметики"; seo.Keywords = "Купить косметику корейскую"; break; default: seo.Title = "Остальное - MyTotto - Онлайн-магазин косметики"; seo.Description = "Интернет-магазин корейской косметики"; seo.Keywords = "Купить косметику корейскую"; break; } return(seo); }
public CreateArticleRequest(string title, string description, ArticleStatus status, SeoData seoData = null, string[] tags = null) { Title = title; Description = description; Status = status; SeoData = seoData; Tags = tags; }
/// <summary> /// Set the SEO information for the product /// </summary> /// <param name="seo">The SEO information</param> public virtual void SetSeoData(SeoData seo) { if (seo == null) { throw new ArgumentNullException("seo"); } Seo = seo; }
public UpdateArticleRequest(long?agentId = null, string title = null, string description = null, ArticleStatus?status = null, SeoData seoData = null, string[] tags = null) { AgentId = agentId; Title = title; Description = description; Status = status; SeoData = seoData; Tags = tags; }
/// <summary> /// Создает экземпляр и инициализирует поля класса. /// </summary> public CatalogPageViewModel ( SeoData seo, Navigation navigation, List <Breadcrumb> breadcrumbs, List <Product> products ) : base(seo, navigation, breadcrumbs) { Products = products.Select(p => new ProductCard(p)).ToList(); }
/// <summary> /// Создает экземпляр и инициализирует поля класса. /// </summary> public ProductPage ( SeoData seo, Navigation navigaton, List <Breadcrumb> breadcrumbs, Product product ) : base(seo, navigaton, breadcrumbs) { Product = new ProductFull(product); }
/// <summary> /// Construct the product /// </summary> protected Product() { this.Variants = new HashSet <Product>(); this.ProductCategories = new HashSet <ProductCategory>(); this.TierPrices = new HashSet <TierPrice>(); this.Attributes = new HashSet <ProductAttribute>(); this.Reviews = new HashSet <ProductReview>(); this.Images = new HashSet <ProductImage>(); Price = new Currency(); Seo = new SeoData(); }
public async Task UpdateCategorySeoData(Guid categoryId, SeoData seo) { var url = UrlBuilder.UpdateCategorySeoDataUrl(categoryId); var response = await Client.PatchAsync(url, JsonContent.Create(seo)); if (!response.IsSuccessStatusCode) { throw new ApplicationException($"Update category {categoryId} seo info call ended with status code {response.StatusCode}"); } }
/// <summary> /// Создает экземпляр и инициализирует поля класса. /// </summary> public BasePage ( SeoData seo, Navigation navigation, List <Breadcrumb> breadcrumbs ) { Navigation = navigation; Seo = new Seo(seo); Breadcrumbs = breadcrumbs ?? new List <Breadcrumb>(); }
public IActionResult Index() { List <Banner> banners = bannersRepository.GetBanners(); List <Product> products = productsRepository.GetAllProducts(); List <Promo> promos = promosRepository.GetAllPromos(); List <PromoProduct> promoProducts = promosRepository.GetAllPromoProducts(); Navigation navigation = commonRepository.GetNavigation(); SeoData seo = commonRepository.GetSeo("main"); var mainPage = new MainPage(seo, navigation, null, banners, products, promos, promoProducts); return(View(mainPage)); }
public async Task <IActionResult> PatchSeo(Guid id, [FromBody] SeoData model) { if (id == Guid.Empty) { _logger.LogError("Empty category id"); return(BadRequest(nameof(id))); } await ControllerServices.UpdateCategorySeoData(id, model); _logger.LogInformation("SEO data updated for category with id {categoryId}", id); return(Ok()); }
protected override Task OnInitializedAsync() { context = new EditContext(Model); editingEnabled = !Readonly; _originalModel = new SeoData { Title = Model.Title, Description = Model.Description, Keywords = Model.Keywords }; return(base.OnInitializedAsync()); }
async Task UpdateBrandSeoData(SeoData seo) { try { await Client.UpdateBrandSeoData(_BrandId, seo); } catch { errorRaised = true; } finally { StateHasChanged(); } }
public async Task SetProductSeo(Guid productId, SeoData seo) { try { var product = await Repository.GetByKeyAsync <Product>(productId); product.SetSeoData(seo); await Repository.SaveChangesAsync(); } catch { throw; } }
public async Task SetCategorySeoData_Should_Throw_ArgumentException_If_CategoryId_Is_Empty() { Repository.IRepository repository = new Mock <Repository.IRepository>().Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = Guid.Empty; SeoData seo = new SeoData { Title = "title", Description = "description" }; var commands = new CategoryCommands(repository, eventBus); var ex = await Assert.ThrowsAsync <ArgumentException>(() => commands.SetCategorySeoData(categoryId, seo)); Assert.Equal(nameof(categoryId), ex.ParamName); }
public async Task SetBrandSeoData(Guid brandId, SeoData seo) { try { var brand = await Repository.GetByKeyAsync <Brand>(brandId); brand.SetSeoData(seo); await Repository.SaveChangesAsync(); } catch { throw; } }
public async Task SetCategorySeoData(Guid categoryId, SeoData seo) { try { var category = await Repository.GetByKeyAsync <Category>(categoryId); category.SetSeoData(seo); await Repository.SaveChangesAsync(); } catch { throw; } }
/// <summary> /// Создает экземпляр и инициализирует поля класса. /// </summary> public MainPage ( SeoData seo, Navigation navigation, List <Breadcrumb> breadcrumbs, List <Banner> banners, List <Product> products, List <Promo> promos, List <PromoProduct> promoProducts ) : base(seo, navigation, breadcrumbs) { Banners = banners.Select(b => new BannerViewModel(b)).ToList(); Promos = promos.Select(p => new PromoViewModel(p)).ToList(); PromoProducts = promoProducts.Select(p => new PromoProductViewModel(p)).ToList(); Products = new ProductsAllViewModel(products); }
void Cancel() { Model = new SeoData { Title = _originalModel.Title, Description = _originalModel.Description, Keywords = _originalModel.Keywords }; if (Readonly) { editingEnabled = false; } StateHasChanged(); }
async Task UpdateProductSeoData(SeoData seo) { try { await Client.UpdateProductSeoData(_ProductId, seo); product.Seo = seo; } catch { errorRaised = true; } finally { StateHasChanged(); } }
/// <summary> /// Создает экземпляр и инициализирует поля класса. /// </summary> public SectionPage ( SeoData seo, Navigation navigation, List <Breadcrumb> breadcrumbs, List <Product> products, int productsCount, CatalogFilters filters, Pagination pagination ) : base(seo, navigation, breadcrumbs) { SectionTitle = Breadcrumbs.LastOrDefault()?.Title; Products = products.Select(p => new ProductCard(p)).ToList(); ProductsCount = productsCount; Filters = filters; Pagination = pagination; }
/// <summary> /// Implementation of <see cref="IProductCommands.SetProductSeo(Guid, SeoData)"/> /// </summary> /// <param name="productId">The product id</param> /// <param name="seo">The SEO information</param> /// <returns></returns> public virtual async Task SetProductSeo(Guid productId, SeoData seo) { try { if (productId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(productId)); } var product = await Repository.GetByKeyAsync <Product>(productId); product.SetSeoData(seo); await Repository.SaveChangesAsync(); } catch { throw; } }
/// <summary> /// Implementation of <see cref="IBrandCommands.SetBrandSeoData(Guid, SeoData)"/> /// </summary> /// <param name="brandId">The brand's id</param> /// <param name="seo">The seo data</param> /// <returns></returns> public virtual async Task SetBrandSeoData(Guid brandId, SeoData seo) { try { if (brandId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(brandId)); } var brand = await Repository.GetByKeyAsync <Brand>(brandId); brand.SetSeoData(seo); await Repository.SaveChangesAsync(); } catch { throw; } }
/// <summary> /// Implementation of <see cref="ICategoryCommands.SetCategorySeoData(Guid, SeoData)"/> /// </summary> /// <param name="categoryId">The category id</param> /// <param name="seo">The seo information</param> /// <returns></returns> public virtual async Task SetCategorySeoData(Guid categoryId, SeoData seo) { try { if (categoryId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(categoryId)); } var category = await Repository.GetByKeyAsync <Category>(categoryId); category.SetSeoData(seo); await Repository.SaveChangesAsync(); } catch { throw; } }
public async Task SetCategorySeoData_Should_Set_The_Seo_Data_With_The_Specified_Values() { var category = Category.Create("code", "name", "url"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(It.IsAny <Guid>())) .Returns(Task.FromResult(category)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; SeoData seo = new SeoData { Title = "title", Description = "description" }; var commands = new CategoryCommands(repository, eventBus); await commands.SetCategorySeoData(categoryId, seo); Assert.Equal(seo.Title, category.Seo.Title); Assert.Equal(seo.Description, category.Seo.Description); }
public async Task SetBrandSeoData_Should_Set_SeoData_With_Specified_Values() { var brand = Brand.Create("brand to edit", "brand-to-edit"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Brand>(It.IsAny <Guid>())) .Returns(Task.FromResult(brand)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid brandId = brand.Id; SeoData seo = new SeoData { Title = "title", Description = "description" }; var commands = new BrandCommands(repository, eventBus); await commands.SetBrandSeoData(brandId, seo); Assert.NotNull(brand.Seo); Assert.Equal(seo.Title, brand.Seo.Title); Assert.Equal(seo.Description, brand.Seo.Description); }
public async Task UpdateProductSeoData(Guid productId, SeoData model) => await Commands.SetProductSeo(productId, model);
public IActionResult Section ( string categoryUrl = "", string subcategoryUrl = "", string groupUrl = "", CatalogCountItems count = CatalogCountItems.Small, CatalogSortingType sorting = CatalogSortingType.AscendingTitle, int page = 1, string filters = "", int minPrice = 0, int maxPrice = int.MaxValue, string manufacturer = "", ProductType type = ProductType.Normal ) { if (string.IsNullOrEmpty(categoryUrl)) { return(NotFound()); } Navigation navigation = commonRepository.GetNavigation(); SeoData seo = commonRepository.GetSeo("catalog"); ProductCategory category = catalogRepository.GetCategory(categoryUrl); ProductSubcategory subcategory = catalogRepository.GetSubcategory(subcategoryUrl); ProductGroup group = catalogRepository.GetGroup(groupUrl); if (category == null) { return(NotFound()); } int countItems = productsFilterService.GetPageCountByItems(count); List <Product> products = productsFilterService.Filter ( categoryUrl, subcategoryUrl, groupUrl, count, sorting, page, filters, minPrice, maxPrice, manufacturer, type ); List <Breadcrumb> breadcrumbs = GetBreadcrumbs(category, subcategory, group); var catalogFilters = new CatalogFilters() { MinPrice = (int)products.Min(x => x.Price), MaxPrice = (int)products.Max(x => x.Price), Manufacturers = products.Any() ? products.Select(x => x.Manufacturer).Distinct(new ManufacturerEqualityComparer()).ToList() : new List <Manufacturer>(), CategoryFilters = new List <CategoryFilter>() { new CategoryFilter("Категория 1", new List <CategoryFilterItem>() { new CategoryFilterItem(1, "Увлажняющие", "cat-1-uvlaj"), new CategoryFilterItem(2, "Питательные", "cat-1-pitatel"), new CategoryFilterItem(3, "Натуральные", "cat-1-natural"), new CategoryFilterItem(4, "Дневные", "cat-1-den"), new CategoryFilterItem(5, "Ночные", "cat-1-noch") }), new CategoryFilter("Категория 2", new List <CategoryFilterItem>() { new CategoryFilterItem(6, "Антивозрастные", "cat-2-antivozrast"), new CategoryFilterItem(7, "Жирные", "cat-2-jirnie"), new CategoryFilterItem(8, "Сухие", "cat-2-suhie"), new CategoryFilterItem(9, "Невероятные", "cat-2-neveroyat"), new CategoryFilterItem(10, "Чудесные", "cat-2-chudo") }) } }; int pageCount = products.Count() / countItems != 0 ? products.Count() / countItems : 1; var pagination = new Pagination(page, pageCount); var sectionPage = new SectionPage(seo, navigation, breadcrumbs, products, products.Count, catalogFilters, pagination); return(View(sectionPage)); }
public async Task UpdateCategorySeoData(Guid categoryId, SeoData model) => await Commands.SetCategorySeoData(categoryId, model);