public void OnGoToMyCategories() { CategoryPage Page = new CategoryPage(user); Application.Current.MainPage = Page; }
public CategoryTest() { driver = new ChromeDriver(); categoryPage = new CategoryPage(driver); }
public async Task <IActionResult> Import() { int importCount = 0; int existCount = 0; var site = await api.Sites.GetDefaultAsync(); var catalog = await api.Pages .GetBySlugAsync <CatalogPage> ("catalog"); foreach (Category c in db.Categories.Include(c => c.Products)) { // if the category page already exists, // then skip to the next iteration of the loop CategoryPage cp = await api.Pages.GetBySlugAsync <CategoryPage> ($"catalog/{c.CategoryName.ToLower().Replace(' ', '-') }"); if (cp == null) { importCount++; cp = await CategoryPage.CreateAsync(api); cp.Id = Guid.NewGuid(); cp.SiteId = site.Id; cp.ParentId = catalog.Id; cp.CategoryDetail.CategoryID = c.CategoryID; cp.CategoryDetail.CategoryName = c.CategoryName; cp.CategoryDetail.Description = c.Description; // find the media folder named Categories Guid categoriesFolderID = (await api.Media.GetAllFoldersAsync()) .First(folder => folder.Name == "Categories").Id; // find image with correct filename for category id var image = (await api.Media .GetAllByFolderIdAsync(categoriesFolderID)) .First(media => media.Type == MediaType.Image && media.Filename == $"category{c.CategoryID}.jpeg"); cp.CategoryDetail.CategoryImage = image; if (cp.Products.Count == 0) { // convert the products for this category into // a list of instances of ProductRegion cp.Products = c.Products .Select(p => new ProductRegion { ProductID = p.ProductID, ProductName = p.ProductName, UnitPrice = p.UnitPrice.HasValue ? p.UnitPrice.Value.ToString("c") : "n/a", UnitsInStock = p.UnitsInStock ?? 0 }).ToList(); } cp.Title = c.CategoryName; cp.MetaDescription = c.Description; cp.NavigationTitle = c.CategoryName; cp.Published = DateTime.Now; await api.Pages.SaveAsync(cp); } else { existCount++; } } TempData["import_message"] = $"{existCount} categories already existed. {importCount} new categories imported. "; return(Redirect("~/")); }
#pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { #line 2 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Layout = "CommonPage"; Context.Items["PageStyle"] = "/styles/admin_panel/categories_and_products/work_with_page.css"; User user = Context.Items["User"] as User; CategoryPage categoryPage = Context.Items["CategoryPage"] as CategoryPage; Context.Items["PageName"] = $"{localization.AddProductPageName} {categoryPage?.PageName}"; Template[] templates = Context.Items["Templates"] as Template[]; int? lastTemplate = Context.Items["LastTemplate"] as int?; #line default #line hidden BeginContext(550, 254, true); WriteLiteral("<script src=\"/scripts/admin_panel/insert_tab.js\"></script>\r\n <script src=\"/scripts/admin_panel/checkbox_event_handler.js\"></script>\r\n <form id=\"add-product\" class=\"page-container\">\r\n <input type=\"hidden\" name=\"pageID\""); EndContext(); BeginWriteAttribute("value", " value=\"", 804, "\"", 846, 1); #line 14 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" WriteAttributeValue("", 812, (int)AdminPanelPages.AddProduct, 812, 34, false); #line default #line hidden EndWriteAttribute(); BeginContext(847, 53, true); WriteLiteral(">\r\n <input type=\"hidden\" name=\"itemID\""); EndContext(); BeginWriteAttribute("value", " value=\"", 900, "\"", 925, 1); #line 15 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" WriteAttributeValue("", 908, categoryPage?.ID, 908, 17, false); #line default #line hidden EndWriteAttribute(); BeginContext(926, 3, true); WriteLiteral(">\r\n"); EndContext(); BeginContext(962, 52, true); WriteLiteral(" <input id=\"add-button\" type=\"submit\""); EndContext(); BeginWriteAttribute("value", " value=\"", 1014, "\"", 1056, 1); #line 17 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" WriteAttributeValue("", 1022, Html.Raw(localization.SaveButton), 1022, 34, false); #line default #line hidden EndWriteAttribute(); BeginContext(1057, 89, true); WriteLiteral(" />\r\n <div class=\"blocks\">\r\n <div class=\"left-block\">\r\n"); EndContext(); BeginContext(1181, 43, true); WriteLiteral(" <label for=\"Title\">"); EndContext(); BeginContext(1225, 35, false); #line 21 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.ProductTitle)); #line default #line hidden EndContext(); BeginContext(1260, 101, true); WriteLiteral("*</label>\r\n <input type=\"text\" id=\"Title\" name=\"PageModel.Title\" required />\r\n"); EndContext(); BeginContext(1401, 46, true); WriteLiteral(" <label for=\"PageName\">"); EndContext(); BeginContext(1448, 40, false); #line 24 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.ProductBreadcrumb)); #line default #line hidden EndContext(); BeginContext(1488, 107, true); WriteLiteral("*</label>\r\n <input type=\"text\" id=\"PageName\" name=\"PageModel.PageName\" required />\r\n"); EndContext(); BeginContext(1630, 137, true); WriteLiteral(" <div class=\"price-block\">\r\n <div>\r\n <label for=\"Price\">"); EndContext(); BeginContext(1768, 28, false); #line 29 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.Price)); #line default #line hidden EndContext(); BeginContext(1796, 226, true); WriteLiteral("</label>\r\n <input type=\"number\" id=\"Price\" name=\"PageModel.Price\" />\r\n </div>\r\n <div>\r\n <label for=\"OldPrice\">"); EndContext(); BeginContext(2023, 31, false); #line 33 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.OldPrice)); #line default #line hidden EndContext(); BeginContext(2054, 175, true); WriteLiteral("</label>\r\n <input type=\"number\" id=\"OldPrice\" name=\"PageModel.OldPrice\" />\r\n </div>\r\n </div>\r\n"); EndContext(); BeginContext(2266, 45, true); WriteLiteral(" <label for=\"Barcode\">"); EndContext(); BeginContext(2312, 30, false); #line 38 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.Barcode)); #line default #line hidden EndContext(); BeginContext(2342, 95, true); WriteLiteral("</label>\r\n <input type=\"text\" id=\"Barcode\" name=\"PageModel.Barcode\" />\r\n"); EndContext(); BeginContext(2484, 54, true); WriteLiteral(" <label for=\"ShortDescription\">"); EndContext(); BeginContext(2539, 39, false); #line 41 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.ShortDescription)); #line default #line hidden EndContext(); BeginContext(2578, 223, true); WriteLiteral("</label>\r\n <textarea class=\"short-description\" rows=\"3\" id=\"ShortDescription\" name=\"PageModel.ShortDescription\"></textarea>\r\n </div>\r\n <div class=\"right-block\">\r\n"); EndContext(); BeginContext(2845, 48, true); WriteLiteral(" <label for=\"TemplateId\">"); EndContext(); BeginContext(2894, 31, false); #line 46 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.Template)); #line default #line hidden EndContext(); BeginContext(2925, 88, true); WriteLiteral("</label>\r\n <select id=\"TemplateId\" name=\"PageModel.TemplateId\">\r\n"); EndContext(); #line 48 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" if (lastTemplate.HasValue) { #line default #line hidden BeginContext(3101, 40, true); WriteLiteral(" <option>"); EndContext(); BeginContext(3142, 38, false); #line 50 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.WithoutTemplate)); #line default #line hidden EndContext(); BeginContext(3180, 11, true); WriteLiteral("</option>\r\n"); EndContext(); #line 51 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" } else { #line default #line hidden BeginContext(3287, 49, true); WriteLiteral(" <option selected>"); EndContext(); BeginContext(3337, 38, false); #line 54 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.WithoutTemplate)); #line default #line hidden EndContext(); BeginContext(3375, 11, true); WriteLiteral("</option>\r\n"); EndContext(); #line 55 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" } #line default #line hidden BeginContext(3417, 28, true); WriteLiteral(" "); EndContext(); #line 56 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" foreach (var t in templates) { #line default #line hidden #line 58 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" if (lastTemplate.HasValue && lastTemplate.Value == t.ID) { #line default #line hidden BeginContext(3633, 43, true); WriteLiteral(" <option"); EndContext(); BeginWriteAttribute("value", " value=\"", 3676, "\"", 3689, 1); #line 60 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" WriteAttributeValue("", 3684, t.ID, 3684, 5, false); #line default #line hidden EndWriteAttribute(); BeginContext(3690, 10, true); WriteLiteral(" selected>"); EndContext(); BeginContext(3701, 16, false); #line 60 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(t.Name)); #line default #line hidden EndContext(); BeginContext(3717, 11, true); WriteLiteral("</option>\r\n"); EndContext(); #line 61 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" } else { #line default #line hidden BeginContext(3836, 43, true); WriteLiteral(" <option"); EndContext(); BeginWriteAttribute("value", " value=\"", 3879, "\"", 3892, 1); #line 64 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" WriteAttributeValue("", 3887, t.ID, 3887, 5, false); #line default #line hidden EndWriteAttribute(); BeginContext(3893, 1, true); WriteLiteral(">"); EndContext(); BeginContext(3895, 16, false); #line 64 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(t.Name)); #line default #line hidden EndContext(); BeginContext(3911, 11, true); WriteLiteral("</option>\r\n"); EndContext(); #line 65 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" } #line default #line hidden #line 65 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" } #line default #line hidden BeginContext(3988, 35, true); WriteLiteral(" </select>\r\n"); EndContext(); BeginContext(4058, 43, true); WriteLiteral(" <label for=\"Alias\">"); EndContext(); BeginContext(4102, 28, false); #line 69 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.Alias)); #line default #line hidden EndContext(); BeginContext(4130, 91, true); WriteLiteral("</label>\r\n <input type=\"text\" id=\"Alias\" name=\"PageModel.Alias\" />\r\n"); EndContext(); BeginContext(4267, 53, true); WriteLiteral(" <label for=\"PageDescription\">"); EndContext(); BeginContext(4321, 38, false); #line 72 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.PageDescription)); #line default #line hidden EndContext(); BeginContext(4359, 125, true); WriteLiteral("</label>\r\n <input type=\"text\" id=\"PageDescription\" name=\"PageModel.PageDescription\" maxlength=\"160\">\r\n"); EndContext(); BeginContext(4527, 50, true); WriteLiteral(" <label for=\"PageKeywords\">"); EndContext(); BeginContext(4578, 35, false); #line 75 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.PageKeywords)); #line default #line hidden EndContext(); BeginContext(4613, 105, true); WriteLiteral("</label>\r\n <input type=\"text\" id=\"PageKeywords\" name=\"PageModel.PageKeywords\" />\r\n"); EndContext(); BeginContext(4758, 495, true); WriteLiteral(@" <div class=""checkbox-block""> <input type=""checkbox"" id=""Published"" name=""PageModel.Published"" value=""true"" checked /> <script> let publishedCheckbox = document.getElementById('Published'); publishedCheckbox.addEventListener('click', checkboxEventHandler); </script> <label for=""Published"">"); EndContext(); BeginContext(5254, 32, false); #line 84 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.Published)); #line default #line hidden EndContext(); BeginContext(5286, 42, true); WriteLiteral("</label>\r\n </div>\r\n"); EndContext(); BeginContext(5377, 518, true); WriteLiteral(@" <div class=""checkbox-block""> <input type=""checkbox"" id=""SpecialProduct"" name=""PageModel.SpecialProduct"" value=""false"" /> <script> let specialProductCheckbox = document.getElementById('SpecialProduct'); specialProductCheckbox.addEventListener('click', checkboxEventHandler); </script> <label for=""SpecialProduct"">"); EndContext(); BeginContext(5896, 37, false); #line 93 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.SpecialProduct)); #line default #line hidden EndContext(); BeginContext(5933, 42, true); WriteLiteral("</label>\r\n </div>\r\n"); EndContext(); BeginContext(6014, 483, true); WriteLiteral(@" <div class=""checkbox-block""> <input type=""checkbox"" id=""IsIndex"" name=""PageModel.IsIndex"" value=""true"" checked /> <script> let isIndexCheckbox = document.getElementById('IsIndex'); isIndexCheckbox.addEventListener('click', checkboxEventHandler); </script> <label for=""IsIndex"">"); EndContext(); BeginContext(6498, 30, false); #line 102 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.IsIndex)); #line default #line hidden EndContext(); BeginContext(6528, 42, true); WriteLiteral("</label>\r\n </div>\r\n"); EndContext(); BeginContext(6610, 489, true); WriteLiteral(@" <div class=""checkbox-block""> <input type=""checkbox"" id=""IsFollow"" name=""PageModel.IsFollow"" value=""true"" checked /> <script> let isFollowCheckbox = document.getElementById('IsFollow'); isFollowCheckbox.addEventListener('click', checkboxEventHandler); </script> <label for=""IsFollow"">"); EndContext(); BeginContext(7100, 31, false); #line 111 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.IsFollow)); #line default #line hidden EndContext(); BeginContext(7131, 42, true); WriteLiteral("</label>\r\n </div>\r\n"); EndContext(); BeginContext(7221, 531, true); WriteLiteral(@" <div class=""checkbox-block""> <input type=""checkbox"" id=""AddParagraphTag"" name=""PageModel.AddParagraphTag"" value=""true"" checked /> <script> let addParagraphTagCheckbox = document.getElementById('AddParagraphTag'); addParagraphTagCheckbox.addEventListener('click', checkboxEventHandler); </script> <label for=""AddParagraphTag"">"); EndContext(); BeginContext(7753, 38, false); #line 120 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.AddParagraphTag)); #line default #line hidden EndContext(); BeginContext(7791, 94, true); WriteLiteral("</label>\r\n </div>\r\n </div>\r\n </div>\r\n"); EndContext(); BeginContext(7914, 37, true); WriteLiteral(" <label for=\"Content\">"); EndContext(); BeginContext(7952, 30, false); #line 125 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.Content)); #line default #line hidden EndContext(); BeginContext(7982, 633, true); WriteLiteral(@"</label> <textarea id=""Content"" name=""PageModel.Content""></textarea> </form> <script> function errorHandler(formElement) { let errorMsgElement = document.getElementById('error-msg'); if (errorMsgElement === null) { errorMsgElement = document.createElement('span'); errorMsgElement.setAttribute('id', 'error-msg'); formElement.insertBefore(errorMsgElement, formElement.firstChild); } errorMsgElement.textContent = '"); EndContext(); BeginContext(8616, 37, false); #line 136 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.IncorrectInput)); #line default #line hidden EndContext(); BeginContext(8653, 170, true); WriteLiteral("\';\r\n }\r\n function responseHandler(request, formElement) {\r\n if (request.status == 201) {\r\n alert(\'"); EndContext(); BeginContext(8824, 35, false); #line 140 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(Html.Raw(localization.ProductAdded)); #line default #line hidden EndContext(); BeginContext(8859, 5, true); WriteLiteral("\');\r\n"); EndContext(); #line 141 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" if (SecurityFunctions.HasAccessTo(AdminPanelPages.EditCategory, user, Context)) { #line default #line hidden BeginContext(8997, 24, true); WriteLiteral(" "); EndContext(); BeginContext(9023, 58, true); WriteLiteral("location.replace(request.getResponseHeader(\'location\'));\r\n"); EndContext(); #line 144 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" } else { #line default #line hidden BeginContext(9165, 24, true); WriteLiteral(" "); EndContext(); BeginContext(9191, 64, true); WriteLiteral("location.replace(location.origin + location.pathname + \'?pageID="); EndContext(); BeginContext(9257, 37, false); #line 147 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write((int)AdminPanelPages.CategoryProducts); #line default #line hidden EndContext(); BeginContext(9295, 8, true); WriteLiteral("&itemID="); EndContext(); BeginContext(9304, 16, false); #line 147 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" Write(categoryPage?.ID); #line default #line hidden EndContext(); BeginContext(9320, 5, true); WriteLiteral("\');\r\n"); EndContext(); #line 148 "C:\Users\79622\Desktop\Github\StoreCMS\StoreCMS\Views\AdminPanel\CategoriesAndProducts\AddProduct.cshtml" } #line default #line hidden BeginContext(9352, 574, true); WriteLiteral(@" } else if (request.status == 422) { errorHandler(formElement); } } document.getElementById('add-button').addEventListener('click', createSendDataEventHandler('POST', 'add-product', responseHandler, errorHandler)); document.getElementById('ShortDescription').addEventListener('keydown', insertTabEventHandler); document.getElementById('Content').addEventListener('keydown', insertTabEventHandler); </script>"); EndContext(); }
public void CheckOutCartinSignInPage() { //driver.FindElement(By.XPath("//*[@class='login']")).Click(); IndexPage ip = new IndexPage(driver); ip.hoverCategory(Category.Women); ip.openSubCategory("Evening Dresses"); CategoryPage cat = new CategoryPage(driver); cat.hoverProduct(); cat.clickaddToCart(); cat.clickProceedToCO(); OrderPage op = new OrderPage(driver); op.clickProceedToCO(); SignIn si = new SignIn(driver); si.enterRegisteredEmailAddress("*****@*****.**"); si.enterPassword("Automation123"); si.clickSignIn(); MyAccount myacc = new MyAccount(driver); myacc.hoverShoppingCart(); myacc.openCart(); op.clickProceedToCO(); op.clickNewAddress(); AddressPage ap = new AddressPage(driver); ap.enterFirstName("Krish"); ap.enterLastName("Krishna"); ap.enterAddress1("45 Pinnaker St"); ap.enterCity("Atlanta"); ap.enterIdState("Alaska"); ap.enterPostCode("11111"); ap.enterCountry("United States"); ap.enterPhone("1111111111"); ap.enterPhoneMobile("3333333333333"); ap.enterAlias("Doct9994"); ap.clickSaveAddress(); op.clickProceedToCheckOut(); op.clickTermsofService(); op.clickProceedToCheckOut(); PaymentPage pp = new PaymentPage(driver); op.clickPayByBankWire(); pp.clickConfirmOrder(); OrderConfirmationPage ocp = new OrderConfirmationPage(driver); Assert.IsTrue(ocp.isOrderConfirmationSuccessDisplayed()); }
public async Task <IActionResult> Import() { var site = await api.Sites.GetDefaultAsync(); var catalog = await api.Pages .GetBySlugAsync <CatalogPage>("catalog"); var categories = db.Categories.Include(c => c.Products); foreach (var category in categories) { // if the category page already exists, // then skip to the next iteration of the loop CategoryPage categoryPage = await api.Pages.GetBySlugAsync <CategoryPage>( $"catalog/{category.CategoryName.ToLower()}"); if (categoryPage == null) { //categoryPage = CategoryPage.Create(api); categoryPage = await CategoryPage.CreateAsync(api); categoryPage.Id = Guid.NewGuid(); categoryPage.SiteId = site.Id; categoryPage.ParentId = catalog.Id; categoryPage.CategoryDetail.CategoryID = category.CategoryID; categoryPage.CategoryDetail.CategoryName = category.CategoryName; categoryPage.CategoryDetail.Description = category.Description; // find image with correct filename for category id var image = (await api.Media.GetAllByFolderIdAsync()) .First(media => media.Type == MediaType.Image && media.Filename == $"category{category.CategoryID}.jpeg"); categoryPage.CategoryDetail.CategoryImage = image; } if (categoryPage.Products.Count == 0) { // convert the products for this category into // a list of instances of ProductRegion categoryPage.Products = category.Products .Select(p => new ProductRegion { ProductID = p.ProductID, ProductName = p.ProductName, UnitPrice = p.UnitPrice.HasValue ? p.UnitPrice.Value.ToString("c") : "n/a", UnitsInStock = p.UnitsInStock ?? 0 }).ToList(); } categoryPage.Title = category.CategoryName; categoryPage.MetaDescription = category.Description; categoryPage.NavigationTitle = category.CategoryName; categoryPage.Published = DateTime.Now; await api.Pages.SaveAsync(categoryPage); } return(Redirect("~/")); }
public App() { InitializeComponent(); MainPage = new CategoryPage(); }
public ActionResult Category(int pGroupId = 0) { try { CreateRepos(); ProductCategoryPageContainer model = new ProductCategoryPageContainer(); int nPage = Convert.ToInt32(Request.QueryString["p"]); if (nPage < 1) { nPage = 1; } List <Product> mProductList = new List <Product>(); List <ProductCategoryPage> mProductPageList = new List <ProductCategoryPage>(); List <ProductType> mProductTypeList; ProductType ProductCategory = ProductRepos.LayLoaiSanPhamTheoId(pGroupId); if (ProductCategory != null) { CategoryPage CategoryPage = ProductHelper.getProductsByCategory(ProductCategory.ID, nPage); model.Products = CategoryPage.Products; model.ProductTotal = CategoryPage.ProductTotal; model.Brands = ProductRepos.getRandomBrands(ProductCategory.ID, 6); if (ProductCategory.Parent == 0) { mProductTypeList = ProductRepos.getProductTypeByProductType(ProductCategory.ID);//lay danh sach cap 1 } else { mProductTypeList = new List <ProductType>(); mProductTypeList.Add(ProductCategory); //mProductTypeList = productRepository.getProductTypeByProductType((int)mProductType.Parent);//lay danh sach cap 2 } if (mProductTypeList.Count > 0) { foreach (ProductType it in mProductTypeList) { mProductPageList.Add(ProductHelper.GetCategoryPage(it, nPage)); } } else { mProductPageList.Add(ProductHelper.GetCategoryPage(ProductCategory, nPage)); } //lay danh sach cac nhom so che //mSoCheList = productRepos.LayProductTypeTheoParentId(147); //Model.ProductTypeList = mSoCheList; //lay cac san pham ban chay //mBestBuyList = productRepos.getBestBuyWithType(1, 10, 147, "10030"); //Model.ProductList = mBestBuyList; } model.List = mProductPageList; model.ProductType = ProductCategory; model.BestSeller = ProductRepos.getProductsRandom(); //if (mProductList.Count < 40) // Model.IsEnd = true; model.Page = nPage; return(View("Category", model)); //if (!Request.Browser.IsMobileDevice) // return View("Category", model); //else // return View("MobileCategory", model); } catch (Exception ex) { return(Content(ex.ToString())); } }
/// <summary> /// 添加栏目 /// </summary> /// <param name="category">基本信息</param> /// <param name="page">单页栏目信息</param> /// <returns></returns> public Response Add(ContentManageSystem.Entity.Models.Category.Category category, CategoryPage page) { Response _response = new Response() { Code = 1 }; _response = base.Add(category); page.CategoryID = category.CategoryID; var _pageManager = new CategoryPageServices(); _pageManager.Add(page); return(_response); }
/// <summary> /// 更新栏目 /// </summary> /// <param name="category">栏目</param> /// <param name="page">单页信息</param> /// <returns></returns> public Response Update(ContentManageSystem.Entity.Models.Category.Category category, CategoryPage page) { Response _response = new Response() { Code = 1 }; _response = base.Update(category); if (_response.Code == 1) { page.CategoryID = category.CategoryID; var _pageManager = new CategoryPageServices(); if (page.CategoryPageID == 0) { _response = _pageManager.Add(page); } else { _response = _pageManager.Update(page); } } if (_response.Code == 1) { _response.Message = "更新栏目成功!"; } return(_response); }
public ActionResult Add(Category _category) { if (ModelState.IsValid) { //检查父栏目 if (_category.ParentID > 0) { var _parentCategory = categoryManager.Find(_category.ParentID); if (_parentCategory == null) { ModelState.AddModelError("ParentID", "父栏目不存在,请刷新后重新添加"); } else if (_parentCategory.Type != CategoryType.General) { ModelState.AddModelError("ParentID", "父栏目不允许添加子栏目"); } else { _category.ParentPath = _parentCategory.ParentPath + "," + _parentCategory.ID; _category.Depth = _parentCategory.Depth + 1; } } else { _category.ParentPath = "0"; _category.Depth = 0; } //栏目基本信息保存 Response _response = new Response() { Code = 0, Message = "初始失败信息" }; //根据栏目类型进行处理 switch (_category.Type) { case CategoryType.General: var _general = new CategoryGeneral(); TryUpdateModel(_general); _response = categoryManager.Add(_category, _general); break; case CategoryType.Page: return(View("Prompt", new Prompt() { Title = "暂未实现", Message = "暂未实现单页栏目添加" })); var _page = new CategoryPage(); TryUpdateModel(_page); _response = categoryManager.Add(_category, _page); break; case CategoryType.Link: return(View("Prompt", new Prompt() { Title = "暂未实现", Message = "暂未实现外部链接添加" })); var _link = new CategoryLink(); TryUpdateModel(_link); _response = categoryManager.Add(_category, _link); break; } if (_response.Code == 1) { return(View("Prompt", new WebPage.Models.Prompt() { Title = "添加栏目成功", Message = "添加栏目【" + _category.Name + "】成功" })); } else { return(View("Prompt", new Prompt() { Title = "添加失败", Message = "添加栏目【" + _category.Name + "】时发生系统错误,未能保存到数据库,请重试" })); } } return(View(_category)); }
public ActionResult Modify(int id, FormCollection form) { Category _category = categoryManager.Find(id); if (_category == null) { return(View("Prompt", new Prompt() { Title = "错误", Message = "栏目不存在!" })); } if (TryUpdateModel(_category, new string[] { "Type", "ParentID", "Name", "Description", "Order", "Target" })) { //检查父栏目 if (_category.ParentID > 0) { var _parentCategory = categoryManager.Find(_category.ParentID); if (_parentCategory == null) { ModelState.AddModelError("ParentID", "父栏目不存在,请刷新后重新添加"); } else if (_parentCategory.Type != CategoryType.General) { ModelState.AddModelError("ParentID", "父栏目不允许添加子栏目"); } else if (_parentCategory.ParentPath.IndexOf(_category.ParentPath) >= 0) { ModelState.AddModelError("ParentID", "父栏目不能是其本身或其子栏目"); } else { _category.ParentPath = _parentCategory.ParentPath + "," + _parentCategory.ID; _category.Depth = _parentCategory.Depth + 1; } } else { _category.ParentPath = "0"; _category.Depth = 0; } //栏目基本信息保存 Response _response = new Response() { Code = 0, Message = "初始失败信息" }; //根据栏目类型进行处理 switch (_category.Type) { case CategoryType.General: var _general = _generalManager.Find(g => g.CategoryID == id); if (_general == null) { _general = new CategoryGeneral() { CategoryID = id, View = "Index", ContentView = "Index" } } ; if (TryUpdateModel(_general, new string[] { "View", "ContentTypeID", "ContentView" })) { _response = categoryManager.Update(_category, _general); } break; //暂不实现 case CategoryType.Page: return(View("Prompt", new Prompt() { Title = "暂未实现", Message = "暂未实现单页栏目修改" })); var _pageManager = new CategoryPageManager(); var _page = _pageManager.Find(p => p.CategoryID == id); if (_page == null) { _page = new CategoryPage() { CategoryID = id, View = "index" } } ; if (TryUpdateModel(_page)) { _response = categoryManager.Update(_category, _page); } break; //暂不实现 case CategoryType.Link: return(View("Prompt", new Prompt() { Title = "暂未实现", Message = "暂未实现外部链接修改" })); var _linkManager = new CategoryLinkManager(); var _link = _linkManager.Find(l => l.CategoryID == id); if (_link == null) { _link = new CategoryLink() { CategoryID = id, Url = "http://" } } ; if (TryUpdateModel(_link)) { _response = categoryManager.Update(_category, _link); } break; } if (ModelState.IsValid) { if (_response.Code == 1) { return(View("Prompt", new Prompt() { Title = "修改栏目成功", Message = "修改栏目【" + _category.Name + "】成功" })); } else { return(View("Prompt", new Prompt() { Title = "修改栏目失败", Message = "修改栏目【" + _category.Name + "】时发生系统错误,未能保存到数据库,请重试" })); } } } return(View(_category)); }