protected virtual async Task InstallNews() { var defaultLanguage = _languageRepository.Table.FirstOrDefault(); var news = new List <NewsItem> { new NewsItem { AllowComments = false, Title = "About Grandnode", Short = "It's stable and highly usable. From downloads to documentation, www.grandnode.com offers a comprehensive base of information, resources, and support to the grandnode community.", Full = "<p>For full feature list go to <a href=\"https://grandnode.com\">grandnode.com</a></p><p>Providing outstanding custom search engine optimization, web development services and e-commerce development solutions to our clients at a fair price in a professional manner.</p>", Published = true, CreatedOnUtc = DateTime.UtcNow, }, new NewsItem { AllowComments = false, Title = "Grandnode new release!", Short = "grandnode includes everything you need to begin your e-commerce online store. We have thought of everything and it's all included! grandnode is a fully customizable shopping cart", Full = "<p>Grandnode includes everything you need to begin your e-commerce online store. We have thought of everything and it's all included!</p>", Published = true, CreatedOnUtc = DateTime.UtcNow.AddSeconds(1), }, new NewsItem { AllowComments = false, Title = "New online store is open!", Short = "The new grandnode store is open now! We are very excited to offer our new range of products. We will be constantly adding to our range so please register on our site.", Full = "<p>Our online store is officially up and running. Stock up for the holiday season! We have a great selection of items. We will be constantly adding to our range so please register on our site, this will enable you to keep up to date with any new products.</p><p>All shipping is worldwide and will leave the same day an order is placed! Happy Shopping and spread the word!!</p>", Published = true, CreatedOnUtc = DateTime.UtcNow.AddSeconds(2), }, }; await _newsItemRepository.InsertAsync(news); //search engine names foreach (var newsItem in news) { newsItem.SeName = SeoExtensions.GenerateSlug(newsItem.Title, false, false, false); await _entityUrlRepository.InsertAsync(new EntityUrl { EntityId = newsItem.Id, EntityName = "NewsItem", LanguageId = "", IsActive = true, Slug = newsItem.SeName }); await _newsItemRepository.UpdateAsync(newsItem); } }
protected virtual async Task InstallVendors() { var vendors = new List <Vendor> { new Vendor { Name = "Vendor 1", Email = "*****@*****.**", Description = "Some description...", AdminComment = "", PictureId = "", Active = true, DisplayOrder = 1, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9, 18", }, new Vendor { Name = "Vendor 2", Email = "*****@*****.**", Description = "Some description...", AdminComment = "", PictureId = "", Active = true, DisplayOrder = 2, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9, 18", } }; await _vendorRepository.InsertAsync(vendors); //search engine names foreach (var vendor in vendors) { var seName = SeoExtensions.GenerateSlug(vendor.Name, false, false, false); await _entityUrlRepository.InsertAsync(new EntityUrl { EntityId = vendor.Id, EntityName = "Vendor", LanguageId = "", IsActive = true, Slug = seName }); vendor.SeName = seName; await _vendorRepository.UpdateAsync(vendor); } }
protected virtual async Task InstallBlogPosts() { var blogPosts = new List <BlogPost> { new BlogPost { AllowComments = false, Title = "How GrandNode became the real open-source e-Commerce platform?", BodyOverview = "<p>There are many e-commerce solutions on the market. Is everyone open-source? No, and even if they say yes, it may turn out to be a lie. GrandNode is a true open-source based on .NET Core and MongoDB. No hidden license fees, no additional licensing conditions. Pure open-source and GPL-3 license.</p>", Body = "<p>There are many e-commerce solutions on the market. Is every open-source? No, and even if they say yes, it may turn out to be a lie. GrandNode is a true open-source platform based on .NET Core and MongoDB. No hidden license fees, no additional licensing conditions. Pure open-source and GPL-3 license.</p><p>An open-source platform shouldn't block your development. Forcing the leaving of information about the platform, paid licenses, obtaining paid license keys is an artificial invention that makes the platform paid and complicated.</p>", Tags = "e-commerce, blog, moey", CreatedOnUtc = DateTime.UtcNow, }, new BlogPost { AllowComments = false, Title = "About GrandNode", BodyOverview = "<p>GrandNode is one of a kind open-source e-commerce platform. Thanks to most advanced ASP.NET Core framework and out of the box set of features it makes a perfect fit for multiple e-business models.</p>", Body = "<p>Meet the flexible, the most versatile open-source e-commerce platform on the market. Use GrandNode and its ready-to-use integrations to sell everywhere with a single platform. GrandNode guarantees functionalities for now and for the future. We ensure both, the base needs of each e-commerce, and future features needed for expansion. GrandNode is one platform that suits various business models. It can successfully empower traditional B2C & B2B stores, helping local brands expand globally. Our solution supports booking processes, facilitates the management of the availability calendar and even enables the sale of online courses.</p>", Tags = "e-commerce, grandnode, sample tag, money", CreatedOnUtc = DateTime.UtcNow.AddSeconds(1), }, }; await _blogPostRepository.InsertAsync(blogPosts); //search engine names foreach (var blogPost in blogPosts) { var seName = SeoExtensions.GenerateSlug(blogPost.Title, false, false, false); await _entityUrlRepository.InsertAsync(new EntityUrl { EntityId = blogPost.Id, EntityName = "BlogPost", LanguageId = "", IsActive = true, Slug = seName }); blogPost.SeName = seName; await _blogPostRepository.UpdateAsync(blogPost); } }
public void SeoExtensionsTest() { var charConversions = "ä:a;ö:o;ü:u;т:t;е:e;с:s;т:t"; //german letters with diacritics Assert.AreEqual("testaou", SeoExtensions.GenerateSlug("testäöü", true, false, false, charConversions)); Assert.AreEqual("test", SeoExtensions.GenerateSlug("testäöü", false, false, false)); //russian letters Assert.AreEqual("testtest", SeoExtensions.GenerateSlug("testтест", true, false, false, charConversions)); Assert.AreEqual("test", SeoExtensions.GenerateSlug("testтест", false, false, false)); Assert.AreEqual("test", SeoExtensions.GenerateSlug("testтест", false, false, false)); Assert.AreEqual("testтест", SeoExtensions.GenerateSlug("testтест", false, true, false)); //other Assert.AreEqual("abcdefghijklmnopqrstuvwxyz1234567890", SeoExtensions.GenerateSlug("abcdefghijklmnopqrstuvwxyz1234567890", false, false, false)); Assert.AreEqual("test-test", SeoExtensions.GenerateSlug("test test", false, false, false)); Assert.AreEqual("test-test", SeoExtensions.GenerateSlug("test test", false, false, false)); }
/// <summary> /// Get picture SEO friendly name /// </summary> /// <param name="name">Name</param> /// <returns>Result</returns> public virtual string GetPictureSeName(string name) { return(SeoExtensions.GenerateSlug(name, true, false)); }
public void GenerateSlug_ReturnExpectedResult() { Assert.AreEqual(SeoExtensions.GenerateSlug("iphone10plus", false, false, false), "iphone10plus"); Assert.AreEqual(SeoExtensions.GenerateSlug("iphone 10 plus", false, false, false), "iphone-10-plus"); Assert.AreEqual(SeoExtensions.GenerateSlug("iphOnE 10 Plus", false, false, false), "iphone-10-plus"); }
protected virtual async Task InstallBrands() { var pictureService = _serviceProvider.GetRequiredService <IPictureService>(); var downloadService = _serviceProvider.GetRequiredService <IDownloadService>(); var sampleImagesPath = GetSamplesPath(); var brandLayoutInGridAndLines = _brandLayoutRepository.Table.FirstOrDefault(pt => pt.Name == "Grid or Lines"); if (brandLayoutInGridAndLines == null) { throw new Exception("Brand layout cannot be loaded"); } var allbrands = new List <Brand>(); var brandXiaomi = new Brand { Name = "Xiaomi", BrandLayoutId = brandLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; brandXiaomi.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "brand_xiaomi.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Xiaomi"), "", "", false, Domain.Common.Reference.Brand, brandXiaomi.Id)).Id; await _brandRepository.InsertAsync(brandXiaomi); allbrands.Add(brandXiaomi); var brandDell = new Brand { Name = "Dell", BrandLayoutId = brandLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", Published = true, DisplayOrder = 5, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; brandDell.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "brand_dell.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Dell"), "", "", false, Domain.Common.Reference.Brand, brandDell.Id)).Id; await _brandRepository.InsertAsync(brandDell); allbrands.Add(brandDell); var brandAdidas = new Brand { Name = "Adidas", BrandLayoutId = brandLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", Published = true, DisplayOrder = 5, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; brandAdidas.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "brand_adidas.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Adidas"), "", "", false, Domain.Common.Reference.Brand, brandAdidas.Id)).Id; await _brandRepository.InsertAsync(brandAdidas); allbrands.Add(brandAdidas); //search engine names foreach (var brand in allbrands) { brand.SeName = SeoExtensions.GenerateSlug(brand.Name, false, false, true); await _entityUrlRepository.InsertAsync(new EntityUrl { EntityId = brand.Id, EntityName = "Brand", LanguageId = "", IsActive = true, Slug = brand.SeName }); await _brandRepository.UpdateAsync(brand); } }
protected virtual async Task InstallSpecificationAttributes() { var sa1 = new SpecificationAttribute { Name = "Screensize", DisplayOrder = 1, SeName = SeoExtensions.GenerateSlug("Screensize", false, false, false), }; await _specificationAttributeRepository.InsertAsync(sa1); sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "13.0''", DisplayOrder = 2, SeName = SeoExtensions.GenerateSlug("13.0''", false, false, false), }); sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "13.3''", DisplayOrder = 3, SeName = SeoExtensions.GenerateSlug("13.3''", false, false, false), }); sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "14.0''", DisplayOrder = 4, SeName = SeoExtensions.GenerateSlug("14.0''", false, false, false), }); sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "15.0''", DisplayOrder = 4, SeName = SeoExtensions.GenerateSlug("15.0''", false, false, false), }); sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "15.6''", DisplayOrder = 5, SeName = SeoExtensions.GenerateSlug("15.6''", false, false, false), }); await _specificationAttributeRepository.UpdateAsync(sa1); var sa2 = new SpecificationAttribute { Name = "CPU Type", DisplayOrder = 2, SeName = SeoExtensions.GenerateSlug("CPU Type", false, false, false), }; await _specificationAttributeRepository.InsertAsync(sa2); sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "Intel Core i5", DisplayOrder = 1, SeName = SeoExtensions.GenerateSlug("Intel Core i5", false, false, false), }); sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "Intel Core i7", DisplayOrder = 2, SeName = SeoExtensions.GenerateSlug("Intel Core i7", false, false, false), }); await _specificationAttributeRepository.UpdateAsync(sa2); var sa3 = new SpecificationAttribute { Name = "Memory", DisplayOrder = 3, SeName = SeoExtensions.GenerateSlug("Memory", false, false, false), }; await _specificationAttributeRepository.InsertAsync(sa3); sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "4 GB", DisplayOrder = 1, SeName = SeoExtensions.GenerateSlug("4 GB", false, false, false), }); sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "8 GB", DisplayOrder = 2, SeName = SeoExtensions.GenerateSlug("8 GB", false, false, false), }); sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "16 GB", DisplayOrder = 3, SeName = SeoExtensions.GenerateSlug("16 GB", false, false, false), }); await _specificationAttributeRepository.UpdateAsync(sa3); var sa4 = new SpecificationAttribute { Name = "Hardrive", DisplayOrder = 5, SeName = SeoExtensions.GenerateSlug("Hardrive", false, false, false), }; await _specificationAttributeRepository.InsertAsync(sa4); sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "128 GB", DisplayOrder = 7, SeName = SeoExtensions.GenerateSlug("128 GB", false, false, false), }); sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "500 GB", DisplayOrder = 4, SeName = SeoExtensions.GenerateSlug("500 GB", false, false, false), }); sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption { Name = "1 TB", DisplayOrder = 3, SeName = SeoExtensions.GenerateSlug("1 TB", false, false, false), }); await _specificationAttributeRepository.UpdateAsync(sa4); }
protected virtual async Task InstallCategories() { var pictureService = _serviceProvider.GetRequiredService <IPictureService>(); //sample pictures var sampleImagesPath = GetSamplesPath(); var categoryLayoutInGridAndLines = _categoryLayoutRepository .Table.FirstOrDefault(pt => pt.Name == "Grid or Lines"); if (categoryLayoutInGridAndLines == null) { throw new Exception("Category layout cannot be loaded"); } //categories var allCategories = new List <Category>(); var categoryComputers = new Category { Name = "Computers", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = "", IncludeInMenu = true, Published = true, Flag = "New", FlagStyle = "badge-danger", DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryComputers.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_computers.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Computers"), reference: Domain.Common.Reference.Category, objectId: categoryComputers.Id)).Id; allCategories.Add(categoryComputers); var categoryTablets = new Category { Name = "Tablets", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categoryComputers.Id, IncludeInMenu = true, Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryTablets.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_tablets.jpg"), "image/jpeg", pictureService.GetPictureSeName("Tablets"), reference: Domain.Common.Reference.Category, objectId: categoryTablets.Id)).Id; allCategories.Add(categoryTablets); var categoryNotebooks = new Category { Name = "Notebooks", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categoryComputers.Id, IncludeInMenu = true, Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryNotebooks.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_notebooks.jpg"), "image/jpeg", pictureService.GetPictureSeName("Notebooks"), reference: Domain.Common.Reference.Category, objectId: categoryNotebooks.Id)).Id; allCategories.Add(categoryNotebooks); var categorySmartwatches = new Category { Name = "Smartwatches", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categoryComputers.Id, IncludeInMenu = true, Published = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categorySmartwatches.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_smartwatches.jpg"), "image/jpeg", pictureService.GetPictureSeName("Smartwatches"), reference: Domain.Common.Reference.Category, objectId: categorySmartwatches.Id)).Id; allCategories.Add(categorySmartwatches); var categoryElectronics = new Category { Name = "Electronics", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, ParentCategoryId = "", AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", IncludeInMenu = true, Published = true, ShowOnHomePage = false, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryElectronics.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_electronics.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Electronics"), reference: Domain.Common.Reference.Category, objectId: categoryElectronics.Id)).Id; allCategories.Add(categoryElectronics); var categoryDisplay = new Category { Name = "Display", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categoryElectronics.Id, IncludeInMenu = true, Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryDisplay.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_display.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Display"), reference: Domain.Common.Reference.Category, objectId: categoryDisplay.Id)).Id; allCategories.Add(categoryDisplay); var categorySmartphones = new Category { Name = "Smartphones", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categoryElectronics.Id, IncludeInMenu = true, Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categorySmartphones.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_smartphones.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Smartphones"), reference: Domain.Common.Reference.Category, objectId: categorySmartphones.Id)).Id; allCategories.Add(categorySmartphones); var categoryOthers = new Category { Name = "Others", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, ShowOnHomePage = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categoryElectronics.Id, IncludeInMenu = true, Published = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryOthers.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_accessories.jpg"), "image/jpeg", pictureService.GetPictureSeName("SmAccessoriesartphones"), reference: Domain.Common.Reference.Category, objectId: categoryOthers.Id)).Id; allCategories.Add(categoryOthers); var categorySport = new Category { Name = "Sport", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 9, ParentCategoryId = "", AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9, 12", IncludeInMenu = true, Published = true, ShowOnHomePage = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categorySport.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_sport.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Sport"), reference: Domain.Common.Reference.Category, objectId: categorySport.Id)).Id; allCategories.Add(categorySport); var categoryShoes = new Category { Name = "Shoes", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categorySport.Id, IncludeInMenu = true, Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryShoes.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_shoes.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Shoes"), reference: Domain.Common.Reference.Category, objectId: categoryShoes.Id)).Id; allCategories.Add(categoryShoes); var categoryApparel = new Category { Name = "Apparel", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", ParentCategoryId = categorySport.Id, IncludeInMenu = true, Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryApparel.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_sport.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Apparel"), reference: Domain.Common.Reference.Category, objectId: categoryApparel.Id)).Id; allCategories.Add(categoryApparel); var categoryBalls = new Category { Name = "Balls", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, ParentCategoryId = categorySport.Id, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", IncludeInMenu = true, Published = true, DisplayOrder = 6, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryBalls.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_balls.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Balls"), reference: Domain.Common.Reference.Category, objectId: categoryBalls.Id)).Id; allCategories.Add(categoryBalls); var categoryDigitalDownloads = new Category { Name = "Digital downloads", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, ParentCategoryId = "", AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", IncludeInMenu = true, Published = true, ShowOnHomePage = false, DisplayOrder = 4, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryDigitalDownloads.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_digital_downloads.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Digital downloads"), reference: Domain.Common.Reference.Category, objectId: categoryDigitalDownloads.Id)).Id; allCategories.Add(categoryDigitalDownloads); var categoryLego = new Category { Name = "Lego", CategoryLayoutId = categoryLayoutInGridAndLines.Id, MetaKeywords = "Lego, Dictionary, Textbooks", MetaDescription = "Books category description", PageSize = 6, ParentCategoryId = "", AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", IncludeInMenu = true, Published = true, ShowOnHomePage = true, DisplayOrder = 5, Flag = "Promo!", FlagStyle = "bg-success", CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryLego.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_lego.jpeg"), "image/jpeg", pictureService.GetPictureSeName(categoryLego.Name), reference: Domain.Common.Reference.Category, objectId: categoryLego.Id)).Id; allCategories.Add(categoryLego); var categoryGiftVouchers = new Category { Name = "Gift vouchers", CategoryLayoutId = categoryLayoutInGridAndLines.Id, PageSize = 6, ParentCategoryId = "", AllowCustomersToSelectPageSize = true, PageSizeOptions = "6, 3, 9", IncludeInMenu = true, Published = true, DisplayOrder = 7, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; categoryGiftVouchers.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_gift_cards.jpeg"), "image/jpeg", pictureService.GetPictureSeName(categoryGiftVouchers.Name), reference: Domain.Common.Reference.Category, objectId: categoryGiftVouchers.Id)).Id; allCategories.Add(categoryGiftVouchers); await _categoryRepository.InsertAsync(allCategories); //search engine names foreach (var category in allCategories) { category.SeName = SeoExtensions.GenerateSlug(category.Name, false, false, false); await _entityUrlRepository.InsertAsync(new EntityUrl { EntityId = category.Id, EntityName = "Category", LanguageId = "", IsActive = true, Slug = category.SeName, }); await _categoryRepository.UpdateAsync(category); } }
private async Task From430To440() { #region Install String resources await InstallStringResources("430_440.nopres.xml"); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); await _mediator.Send(new InstallPermissionsCommand() { PermissionProvider = provider }); #endregion #region Update tags on the products var productTagService = _serviceProvider.GetRequiredService <IProductTagService>(); var productRepository = _serviceProvider.GetRequiredService <IRepository <Product> >(); foreach (var tag in await productTagService.GetAllProductTags()) { var builder = Builders <Product> .Filter; var filter = new BsonDocument { new BsonElement("ProductTags", tag.Id) }; var update = Builders <Product> .Update .Set(x => x.ProductTags.ElementAt(-1), tag.Name); await productRepository.Collection.UpdateManyAsync(filter, update); tag.SeName = SeoExtensions.GenerateSlug(tag.Name, false, false); await productTagService.UpdateProductTag(tag); } #endregion #region User api _serviceProvider.GetRequiredService <IRepository <UserApi> >().Collection.Indexes.CreateOne(new CreateIndexModel <UserApi>((Builders <UserApi> .IndexKeys.Ascending(x => x.Email)), new CreateIndexOptions() { Name = "Email", Unique = true, Background = true })); #endregion #region Update message templates (tokens) string ReplaceValue(string value) { string Evaluator(Match match) { return($"{{{{{match.Value.Replace("%", "")}}}}}"); } var evaluator = new MatchEvaluator(Evaluator); return(Regex.Replace(value, @"%([A-Za-z0-9_.]*?)%", new MatchEvaluator(Evaluator))); } var orderProducts = File.ReadAllText(CommonHelper.MapPath("~/App_Data/Upgrade/Order.Products.txt")); var shipmentProducts = File.ReadAllText(CommonHelper.MapPath("~/App_Data/Upgrade/Shipment.Products.txt")); var messagetemplateService = _serviceProvider.GetRequiredService <Grand.Services.Messages.IMessageTemplateService>(); var messagetemplates = await messagetemplateService.GetAllMessageTemplates(string.Empty); foreach (var messagetemplate in messagetemplates) { messagetemplate.Subject = ReplaceValue(messagetemplate.Subject); if (messagetemplate.Body.Contains("%Order.Product(s)%")) { messagetemplate.Body = messagetemplate.Body.Replace("%Order.Product(s)%", orderProducts); } if (messagetemplate.Body.Contains("%Shipment.Product(s)%")) { messagetemplate.Body = messagetemplate.Body.Replace("%Shipment.Product(s)%", shipmentProducts); } messagetemplate.Body = ReplaceValue(messagetemplate.Body); await messagetemplateService.UpdateMessageTemplate(messagetemplate); } #endregion #region Insert message template var eaGeneral = _serviceProvider.GetRequiredService <IRepository <EmailAccount> >().Table.FirstOrDefault(); if (eaGeneral == null) { throw new Exception("Default email account cannot be loaded"); } var messageTemplates = new List <MessageTemplate> { new MessageTemplate { Name = "AuctionExpired.StoreOwnerNotification", Subject = "Your auction to product {{Product.Name}} has expired.", Body = "Hello, <br> Your auction to product {{Product.Name}} has expired without bid.", //this template is disabled by default IsActive = false, EmailAccountId = eaGeneral.Id, } }; await _serviceProvider.GetRequiredService <IRepository <MessageTemplate> >().InsertAsync(messageTemplates); #endregion }
private async Task From460To470() { #region Install String resources await InstallStringResources("EN_460_470.nopres.xml"); #endregion #region MessageTemplates var emailAccount = _serviceProvider.GetRequiredService <IRepository <EmailAccount> >().Table.FirstOrDefault(); if (emailAccount == null) { throw new Exception("Default email account cannot be loaded"); } var messageTemplates = new List <MessageTemplate> { new MessageTemplate { Name = "Customer.EmailTokenValidationMessage", Subject = "{{Store.Name}} - Email Verification Code", Body = "Hello {{Customer.FullName}}, <br /><br />\r\n Enter this 6 digit code on the sign in page to confirm your identity:<br /><br /> \r\n <b>{{Customer.Token}}</b><br /><br />\r\n Yours securely, <br /> \r\n Team", IsActive = true, EmailAccountId = emailAccount.Id, }, new MessageTemplate { Name = "OrderCancelled.VendorNotification", Subject = "{{Store.Name}}. Order #{{Order.OrderNumber}} cancelled", Body = "<p><a href=\"{{Store.URL}}\">{{Store.Name}}</a> <br /><br />Order #{{Order.OrderNumber}} has been cancelled. <br /><br />Order Number: {{Order.OrderNumber}}<br /> Date Ordered: {{Order.CreatedOn}} <br /><br /> ", IsActive = false, EmailAccountId = emailAccount.Id, }, }; await _serviceProvider.GetRequiredService <IRepository <MessageTemplate> >().InsertAsync(messageTemplates); #endregion #region Update store var storeService = _serviceProvider.GetRequiredService <IStoreService>(); foreach (var store in await storeService.GetAllStores()) { store.Shortcut = "Store"; await storeService.UpdateStore(store); } #endregion #region Update specification - sename field var specification = _serviceProvider.GetRequiredService <IRepository <SpecificationAttribute> >(); foreach (var specificationAttribute in specification.Table.ToList()) { specificationAttribute.SeName = SeoExtensions.GenerateSlug(specificationAttribute.Name, false, false); specificationAttribute.SpecificationAttributeOptions.ToList().ForEach(x => { x.SeName = SeoExtensions.GenerateSlug(x.Name, false, false); }); await specification.UpdateAsync(specificationAttribute); } #endregion #region Update product attributes - sename field var attributes = _serviceProvider.GetRequiredService <IRepository <ProductAttribute> >(); foreach (var attribute in attributes.Table.ToList()) { attribute.SeName = SeoExtensions.GenerateSlug(attribute.Name, false, false); await attributes.UpdateAsync(attribute); } #endregion #region Update blog category - sename field var blogcategories = _serviceProvider.GetRequiredService <IRepository <BlogCategory> >(); foreach (var category in blogcategories.Table.ToList()) { category.SeName = SeoExtensions.GenerateSlug(category.Name, false, false); await blogcategories.UpdateAsync(category); } #endregion #region Update media settings var settingsService = _serviceProvider.GetRequiredService <ISettingService>(); var storeInDB = settingsService.GetSettingByKey("Media.Images.StoreInDB", true); await settingsService.SetSetting("MediaSettings.StoreInDb", storeInDB); #endregion }