private void SetFeaturedCategories(MediaModel model) { var cat1 = _getCategoryByUrl.GetByUrl(FeaturedCategoriesInfo.Category1Url); var cat2 = _getCategoryByUrl.GetByUrl(FeaturedCategoriesInfo.Category2Url); var cat3 = _getCategoryByUrl.GetByUrl(FeaturedCategoriesInfo.Category3Url); var cat4 = _getCategoryByUrl.GetByUrl(FeaturedCategoriesInfo.Category4Url); if (cat1 != null) { cat1.FeatureImage = model.FeaturedCategory1.FileUrl; _webpageAdminService.Add(cat1); } if (cat2 != null) { cat2.FeatureImage = model.FeaturedCategory2.FileUrl; _webpageAdminService.Add(cat2); } if (cat3 != null) { cat3.FeatureImage = model.FeaturedCategory3.FileUrl; _webpageAdminService.Add(cat3); } if (cat4 != null) { cat4.FeatureImage = model.FeaturedCategory4.FileUrl; _webpageAdminService.Add(cat4); } }
public string ImportPictures(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { var pictureData = dataReader.GetPictureData(); var mediaCategory = _getByUrl.GetByUrl(NopProductImages); if (mediaCategory == null) { mediaCategory = new MediaCategory { Name = "Nop Product Images", UrlSegment = NopProductImages, IsGallery = false, HideInAdminNav = false }; _mediaCategoryAdminService.Add(mediaCategory); } foreach (var data in pictureData) { using (var fileData = data.GetData()) { var memoryStream = new MemoryStream(); fileData.CopyTo(memoryStream); memoryStream.Position = 0; var mediaFile = _fileService.AddFile(memoryStream, data.FileName, data.ContentType, memoryStream.Length, mediaCategory); nopImportContext.AddEntry(data.Id, mediaFile); } } return(string.Format("{0} pictures imported", pictureData.Count)); }
public IEnumerable <string> GetErrors(DocumentImportDTO item, IList <DocumentImportDTO> allItems) { if (!string.IsNullOrWhiteSpace(item.ParentUrl) && _getWebpageByUrl.GetByUrl(item.ParentUrl) == null && !allItems.Any(x => x.UrlSegment == item.ParentUrl)) { yield return("The parent url specified is not present within the system."); } }
public void Setup(MediaModel mediaModel) { var siteSettings = _configurationProvider.GetSiteSettings <SiteSettings>(); var documentByUrl = _getByUrl.GetByUrl("_ContentLayout"); if (documentByUrl != null) { siteSettings.DefaultLayoutId = documentByUrl.Id; } siteSettings.ThemeName = "Ecommerce"; _configurationProvider.SaveSettings(siteSettings); var ecommerceSettings = _configurationProvider.GetSiteSettings <EcommerceSettings>(); ecommerceSettings.SearchProductsPerPage = "12,20,40"; ecommerceSettings.PreviousPriceText = "Was"; ecommerceSettings.DefaultNoProductImage = mediaModel.AwatiginImage.FileUrl; ecommerceSettings.EnableWishlists = true; ecommerceSettings.ProductUrl = "product/{0}"; ecommerceSettings.CategoryUrl = "category/{0}"; ecommerceSettings.BrandUrl = "brand/{0}"; _configurationProvider.SaveSettings(ecommerceSettings); var paymentSettings = _configurationProvider.GetSiteSettings <PaymentSettings>(); paymentSettings.CashOnDeliveryEnabled = true; _configurationProvider.SaveSettings(paymentSettings); }
public string SaveFile(Webpage webpage, FormPosting formPosting, HttpPostedFileBase file) { var mediaCategory = _mediaCategoryLoader.GetByUrl("file-uploads") ?? CreateFileUploadMediaCategory(); var result = _fileService.AddFile(file.InputStream, webpage.Id + "-" + formPosting.Id + "-" + file.FileName, file.ContentType, file.ContentLength, mediaCategory); return(result.FileUrl); }
public MediaModel Setup() { var model = new MediaModel(); var defaultMediaCategory = _getByUrl.GetByUrl("default"); try { var memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(EcommerceInstallInfo.LogoImageUrl)); model.Logo = _fileService.AddFile(memoryStream, "logo.png", "image/png", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(EcommerceInstallInfo.Slide1ImageUrl)); model.SliderImage1 = _fileService.AddFile(memoryStream, "slide1.jpg", "image/jpeg", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(EcommerceInstallInfo.Slide2ImageUrl)); model.SliderImage2 = _fileService.AddFile(memoryStream, "slide2.jpg", "image/jpeg", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(EcommerceInstallInfo.DeliveryIcon)); model.DeliveryIcon = _fileService.AddFile(memoryStream, "delivery.gif", "image/gif", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(EcommerceInstallInfo.ReturnIcon)); model.ReturnIcon = _fileService.AddFile(memoryStream, "return.gif", "image/gif", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(EcommerceInstallInfo.LocationIcon)); model.LocationIcon = _fileService.AddFile(memoryStream, "location.gif", "image/gif", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(EcommerceInstallInfo.ContactIcon)); model.ContactIcon = _fileService.AddFile(memoryStream, "contact.gif", "image/gif", memoryStream.Length, defaultMediaCategory); //featured category images memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(FeaturedCategoriesInfo.Category1ImageUrl)); model.FeaturedCategory1 = _fileService.AddFile(memoryStream, "cat1.jpg", "image/jpeg", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(FeaturedCategoriesInfo.Category2ImageUrl)); model.FeaturedCategory2 = _fileService.AddFile(memoryStream, "cat2.jpg", "image/jpeg", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(FeaturedCategoriesInfo.Category3ImageUrl)); model.FeaturedCategory3 = _fileService.AddFile(memoryStream, "cat3.jpg", "image/jpeg", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(FeaturedCategoriesInfo.Category4ImageUrl)); model.FeaturedCategory4 = _fileService.AddFile(memoryStream, "cat4.jpg", "image/jpeg", memoryStream.Length, defaultMediaCategory); memoryStream = new MemoryStream(EcommerceInstallHelper.GetFileFromUrl(FeaturedCategoriesInfo.SecureCheckout)); model.SecureCheckout = _fileService.AddFile(memoryStream, "secure-checkout.png", "image/png", memoryStream.Length, defaultMediaCategory); } catch (Exception ex) { } var imgPath = HttpContext.Current.Server.MapPath(EcommerceInstallInfo.AwatingImageUrl); var fileStream = new FileStream(imgPath, FileMode.Open); model.AwatiginImage = _fileService.AddFile(fileStream, Path.GetFileName(imgPath), "image/jpeg", fileStream.Length, defaultMediaCategory); return(model); }
private ArticleList GetArticleList(string url) { string fileName = Path.GetFileName(url); if (fileName == null || !fileName.Equals("rss.xml", StringComparison.InvariantCultureIgnoreCase)) { return(null); } string containerName = url.Substring(1, url.Length - 9); return(_getArticleListByUrl.GetByUrl(containerName)); }
public void Execute(OnAddingArgs <Product> args) { var product = args.Item; if (!product.Variants.Any()) { var productVariant = new ProductVariant { Name = product.Name, TrackingPolicy = TrackingPolicy.DontTrack, }; product.Variants.Add(productVariant); productVariant.Product = product; _session.Transact(s => s.Save(productVariant)); } var mediaCategory = _mediaCategoryByUrl.GetByUrl("product-galleries"); if (mediaCategory == null) { mediaCategory = new MediaCategory { Name = "Product Galleries", UrlSegment = "product-galleries", IsGallery = true, HideInAdminNav = true }; _mediaCategoryAdminService.Add(mediaCategory); } var productGallery = new MediaCategory { Name = product.Name, UrlSegment = "product-galleries/" + product.UrlSegment, IsGallery = true, Parent = mediaCategory, HideInAdminNav = true }; product.Gallery = productGallery; _mediaCategoryAdminService.Add(productGallery); }
public IEnumerable <string> GetErrors(DocumentImportDTO item, IList <DocumentImportDTO> allItems) { if (item.UrlHistory.Count <= 0) { yield break; } var document = _getWebpageByUrl.GetByUrl(item.UrlSegment); if (document == null) { yield break; } var urls = _urlHistoryService.GetAllOtherUrls(document).ToList(); foreach (var url in item.UrlHistory.Where(url => urls.Any(x => x.UrlSegment == url))) { yield return("One of url history segments is already within the system and belongs to another document."); } }
public Webpage Get(RequestContext context, string url = null) { string data = url ?? Convert.ToString(context.RouteData.Values["data"]); if (_cache.ContainsKey(data)) { var page = _cache[data]; if (page != null) { page = page.Unproxy(); } return(page); } Webpage webpage = string.IsNullOrWhiteSpace(data) ? CurrentRequestData.HomePage : _getWebpageByUrl.GetByUrl(data); if (webpage != null && !webpage.Published && !CurrentRequestData.CurrentUserIsAdmin) { webpage = null; } CurrentRequestData.CurrentPage = webpage; if (webpage != null) { if (MrCMSApp.AppWebpages.ContainsKey(webpage.GetType())) { context.RouteData.DataTokens["app"] = MrCMSApp.AppWebpages[webpage.GetType()]; } webpage = webpage.Unproxy(); } _cache[data] = webpage; return(webpage); }
public PageModel Setup(MediaModel mediaModel) { var pageModel = new PageModel(); var productSearch = new ProductSearch { Name = "Categories", UrlSegment = "categories", RevealInNavigation = true }; var categoryContainer = new ProductContainer { Name = "Products", UrlSegment = "products", RevealInNavigation = false }; _webpageAdminService.Add(productSearch); _webpageAdminService.PublishNow(productSearch); _webpageAdminService.Add(categoryContainer); _webpageAdminService.PublishNow(categoryContainer); pageModel.ProductSearch = productSearch; var now = DateTime.UtcNow; var yourBasket = new Cart { Name = "Your Basket", UrlSegment = "basket", RevealInNavigation = false, PublishOn = now }; _webpageAdminService.Add(yourBasket); var enterOrderEmail = new EnterOrderEmail { Name = "Enter Order Email", UrlSegment = "enter-order-email", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 0, PublishOn = now, }; _webpageAdminService.Add(enterOrderEmail); var setPaymentDetails = new PaymentDetails { Name = "Set Payment Details", UrlSegment = "set-payment-details", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 1, PublishOn = now, }; _webpageAdminService.Add(setPaymentDetails); var setDeliveryDetails = new SetShippingDetails { Name = "Set Shipping Details", UrlSegment = "set-shipping-details", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 2, PublishOn = now, }; _webpageAdminService.Add(setDeliveryDetails); var orderPlaced = new OrderPlaced { Name = "Order Placed", UrlSegment = "order-placed", RevealInNavigation = false, Parent = yourBasket, DisplayOrder = 3, PublishOn = now, }; _webpageAdminService.Add(orderPlaced); // User Account var userAccount = new SitemapPlaceholder { Name = "User Account", UrlSegment = "user-account", RevealInNavigation = false, PublishOn = now }; _webpageAdminService.Add(userAccount); var userAccountInfo = new UserAccountInfo { Name = "Account Details", UrlSegment = "user-account-details", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _webpageAdminService.Add(userAccountInfo); var userAccountPassword = new UserAccountChangePassword { Name = "Change Password", UrlSegment = "user-account-change-password", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _webpageAdminService.Add(userAccountPassword); var userAccountAddresses = new UserAccountAddresses { Name = "Account Addresses", UrlSegment = "user-account-addresses", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _webpageAdminService.Add(userAccountAddresses); var editAddress = new UserAccountEditAddress { Name = "Edit Address", UrlSegment = userAccountAddresses.UrlSegment + "/edit-address", RevealInNavigation = false, PublishOn = now, Parent = userAccountAddresses }; _webpageAdminService.Add(editAddress); var userAccountOrders = new UserAccountOrders { Name = "Orders", UrlSegment = "user-account-orders", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _webpageAdminService.Add(userAccountOrders); var userOrder = new UserOrder { Name = "View Order", UrlSegment = "user-account-orders/order", RevealInNavigation = false, PublishOn = now, Parent = userAccountOrders }; _webpageAdminService.Add(userOrder); var userAccountReviews = new UserAccountReviews { Name = "Reviews", UrlSegment = "user-account-reviews", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _webpageAdminService.Add(userAccountReviews); var userAccountRewards = new UserAccountRewardPoints { Name = "Reward Points", UrlSegment = "user-account-reward-points", RevealInNavigation = false, PublishOn = now, Parent = userAccount }; _webpageAdminService.Add(userAccountRewards); // End User Account //Added to cart var addedToCart = new ProductAddedToCart { Name = "Added to Basket", UrlSegment = "add-to-basket", RevealInNavigation = false, PublishOn = now }; _webpageAdminService.Add(addedToCart); pageModel.ProductAddedToCart = addedToCart; var wishlist = new ShowWishlist { Name = "Wishlist", UrlSegment = "wishlist", RevealInNavigation = true, PublishOn = now }; _webpageAdminService.Add(wishlist); var newIn = new NewInProducts { Name = "New In", UrlSegment = "new-in", RevealInNavigation = true, PublishOn = now }; _webpageAdminService.Add(newIn); var about = new TextPage() { Name = "About us", UrlSegment = "about-us", RevealInNavigation = true, PublishOn = now, BodyContent = EcommerceInstallInfo.AboutUsText }; _webpageAdminService.Add(about); //update core pages var homePage = _getByUrl.GetByUrl("home"); if (homePage != null) { homePage.BodyContent = EcommerceInstallInfo.HomeCopy; var templates = _pageTemplateAdminService.Search(new PageTemplateSearchQuery()); var homeTemplate = templates.FirstOrDefault(x => x.Name == "Home Page"); if (homeTemplate != null) { homePage.PageTemplate = homeTemplate; } homePage.SubmitButtonText = "Sign up"; _webpageAdminService.Update(homePage); pageModel.HomePage = homePage; } var page2 = _getByUrl.GetByUrl("page-2"); if (page2 != null)//demopage in core not needed { _webpageAdminService.Delete(page2); } var contactus = _getByUrl.GetByUrl("contact-us"); if (contactus != null)//demopage in core not needed { _webpageAdminService.Delete(contactus); } //Added to cart var contactUs = new ContactUs() { Name = "Contact Us", UrlSegment = "contact-us", RevealInNavigation = true, PublishOn = now, Latitude = 55.01021m, Longitude = -1.44998m, Address = EcommerceInstallInfo.Address, PinImage = mediaModel.Logo.FileUrl, BodyContent = "[form]", FormDesign = EcommerceInstallInfo.ContactFormDesign }; _webpageAdminService.Add(contactUs); GetFormProperties(contactUs); var brandListing = new BrandListing { Name = "Brands", UrlSegment = "brands", RevealInNavigation = true, PublishOn = now, BodyContent = "" }; _webpageAdminService.Add(brandListing); return(pageModel); }
private void SetupEcommerceLayoutWidgets(MediaModel mediaModel, LayoutModel layoutModel) { var linkedImageLogo = new LinkedImage { Name = "Logo", Link = "/", Image = mediaModel.Logo.FileUrl, LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Header Left"), Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 60 }; _widgetService.AddWidget(linkedImageLogo); // Search var searchBox = new SearchBox { Name = "Search", LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Header Middle"), Cache = true, }; _widgetService.AddWidget(searchBox); // Ecommerce user links var userLinks = new EcommerceUserLinks { Name = "Ecommerce User Links", LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "User Links") }; _widgetService.AddWidget(userLinks); //cart widget var cartWidget = new CartWidget { Name = "Cart Widget", LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Header Right") }; _widgetService.AddWidget(cartWidget); //footer links var footerLinksWidget = new TextWidget { LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Footer Area 1"), Name = "Footer links", Text = EcommerceInstallInfo.FooterText1, Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 60 }; _widgetService.AddWidget(footerLinksWidget); footerLinksWidget = new TextWidget { LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Footer Area 2"), Name = "Footer links", Text = EcommerceInstallInfo.FooterText2, Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 60 }; _widgetService.AddWidget(footerLinksWidget); footerLinksWidget = new TextWidget { LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Footer Area 3"), Name = "Footer links", Text = EcommerceInstallInfo.FooterText3, Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 60 }; _widgetService.AddWidget(footerLinksWidget); var afterContentCardsTeaser = new TextWidget { LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "After Content"), Name = "Footer links", Text = EcommerceInstallInfo.AfterContentCardsTeaser, Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 60 }; _widgetService.AddWidget(afterContentCardsTeaser); var page404 = _getByUrl.GetByUrl("404"); var notFoundProducts = new On404SearchWidget { LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "After Content"), Name = "What about these?", Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 60, Webpage = page404 }; _widgetService.AddWidget(notFoundProducts); }
public IEnumerable <string> GetErrors(ProductImportDataTransferObject product) { return((from item in product.Categories where _documentService.GetByUrl(item) == null select string.Format("Category with url: {0} is not present within the system.", item)).ToList()); }
/// <summary> /// Import from DTOs /// </summary> /// <param name="dataTransferObject"></param> public Product ImportProduct(ProductImportDataTransferObject dataTransferObject) { var uniquePage = _uniquePageService.GetUniquePage <ProductContainer>(); var productGalleriesCategory = _getByUrl.GetByUrl("product-galleries"); if (productGalleriesCategory == null) { productGalleriesCategory = new MediaCategory { Name = "Product Galleries", UrlSegment = "product-galleries", IsGallery = true, HideInAdminNav = true }; _mediaCategoryAdminService.Add(productGalleriesCategory); } Product product = _session.Query <Product>() .SingleOrDefault(x => x.UrlSegment == dataTransferObject.UrlSegment) ?? new Product(); product.Parent = uniquePage; product.UrlSegment = dataTransferObject.UrlSegment; product.Name = dataTransferObject.Name; product.BodyContent = dataTransferObject.Description; product.MetaTitle = dataTransferObject.SEOTitle; product.MetaDescription = dataTransferObject.SEODescription; product.MetaKeywords = dataTransferObject.SEOKeywords; product.ProductAbstract = dataTransferObject.Abstract; product.SearchResultAbstract = dataTransferObject.SearchResultAbstract; product.PublishOn = dataTransferObject.PublishDate; bool isNew = false; MediaCategory productGallery = product.Gallery ?? new MediaCategory(); if (product.Id == 0) { isNew = true; product.DisplayOrder = GetParentQuery(uniquePage).Any() ? GetParentQuery(uniquePage) .Select(Projections.Max <Webpage>(webpage => webpage.DisplayOrder)) .SingleOrDefault <int>() : 0; productGallery.Name = product.Name; productGallery.UrlSegment = "product-galleries/" + product.UrlSegment; productGallery.IsGallery = true; productGallery.Parent = productGalleriesCategory; productGallery.HideInAdminNav = true; product.Gallery = productGallery; } SetBrand(dataTransferObject, product); SetCategories(dataTransferObject, product); SetOptions(dataTransferObject, product); ////Url History _importUrlHistoryService.ImportUrlHistory(dataTransferObject, product); ////Specifications _importSpecificationsService.ImportSpecifications(dataTransferObject, product); ////Variants _importProductVariantsService.ImportVariants(dataTransferObject, product); if (isNew) { _session.Transact(session => session.Save(product)); _session.Transact(session => session.Save(productGallery)); } else { _session.Transact(session => session.Update(product)); _session.Transact(session => session.Update(productGallery)); } _importProductImagesService.ImportProductImages(dataTransferObject.Images, product.Gallery); return(product); }