public PartialViewResult SiteBlock(string title) { var routeValues = HttpContext.Request.RequestContext.RouteData.Values; string currentController = (string)routeValues["controller"]; HtmlBlocks result = EntityRepository.HtmlBlocks.Where(s => s.ParentTitle == title && s.SitePage == currentController).FirstOrDefault(); return(PartialView(result)); }
public ViewResult CreateEdit(Guid?Id, string type, string game = null) { switch (type) { case "Product": Product prod = EntityRepository.Products.Where(p => p.ProductId == Id).FirstOrDefault(); if (prod != null) { return(View("Save" + type, new ProductDetails { Product = prod, ProductId = prod.ProductId, GamesList = new SelectList(EntityRepository.Games.Select(g => g.GameName), prod?.ProductGame.GameName ?? "Select Game"), SelectedGame = prod?.ProductGame.GameName, CategoriesList = new SelectList(EntityRepository.Games.Where(g => game == null || g.GameName == game).SelectMany(g => g.ProductCategory).Select(p => p.ProductCategoryName), prod?.ProductCategory.ProductCategoryName ?? "Select Category"), SelectedCategory = prod?.ProductCategory.ProductCategoryName, MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), prod?.SEO.MetaTagTitle ?? "Select Meta tag title from List"), SelectedMetaTagTitle = prod?.SEO.MetaTagTitle, ProductOptions = prod.ProductOptions, ProductName = prod.ProductName, InStock = prod.InStock, PreOrder = prod.PreOrder, ProductEnabled = prod.ProductEnabled, ProductQuantity = prod.ProductQuantity, ProductImageThumb = prod.ProductImageThumb, ProductImage = prod.ProductImage, ProductPriority = prod.ProductPriority, ProductPriceEU = prod.ProductPrice.Where(p => p.Region == "Europe").Select(p => p.Price).FirstOrDefault(), ProductPriceUS = prod.ProductPrice.Where(p => p.Region == "US&Oceania").Select(p => p.Price).FirstOrDefault(), ProductSaleEU = prod.ProductPrice.Where(p => p.Region == "Europe").Select(p => p.ProductSale).FirstOrDefault(), ProductSaleUS = prod.ProductPrice.Where(p => p.Region == "US&Oceania").Select(p => p.ProductSale).FirstOrDefault(), Description = prod.ProductDescription.Description, SubDescriptionTitle1 = prod.ProductDescription.SubDescriptionTitle1, SubDescription1 = prod.ProductDescription.SubDescription1, SubDescriptionTitle2 = prod.ProductDescription.SubDescriptionTitle2, SubDescription2 = prod.ProductDescription.SubDescription2, SubDescriptionTitle3 = prod.ProductDescription.SubDescriptionTitle3, SubDescription3 = prod.ProductDescription.SubDescription3, SubDescriptionTitle4 = prod.ProductDescription.SubDescriptionTitle4, SubDescription4 = prod.ProductDescription.SubDescription4, SubDescriptionTitle5 = prod.ProductDescription.SubDescriptionTitle5, SubDescription5 = prod.ProductDescription.SubDescription5, })); } else { return(View("Save" + type, new ProductDetails { GamesList = new SelectList(EntityRepository.Games.Select(g => g.GameName), "Select Game"), CategoriesList = new SelectList(EntityRepository.Games.Where(g => game == null || g.GameName == game).SelectMany(g => g.ProductCategory).Select(p => p.ProductCategoryName), "Select Category"), MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), "Select Meta tag title from List"), })); } case "TemplateOptions": TemplateOptions templateOptions = EntityRepository.TemplateOptions.Where(p => p.OptionId == Id).FirstOrDefault(); if (templateOptions != null) { return(View("Save" + type, new TemplateOptionDetails { TempOptionId = templateOptions.OptionId, TempOptionName = templateOptions.OptionName, TempOptionType = templateOptions.OptionType, TempOptionParamsDetailsCollection = TemplateOptionDetails.PopulateTempOptionParamsDetailsCollection(templateOptions) })); } else { return(View("Save" + type, new TemplateOptionDetails { })); } case "ProductGame": ProductGame productGame = EntityRepository.Games.Where(p => p.ProductGameId == Id).FirstOrDefault(); if (productGame != null) { return(View("Save" + type, new ProductGameDetails { MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), productGame.SEO?.MetaTagTitle ?? "Select Meta tag title from List"), ProductGameId = productGame.ProductGameId, GameName = productGame.GameName, GameDescription = productGame.GameDescription, GameShortUrl = productGame.GameShortUrl, GameSeoId = productGame.GameSeoId })); } else { return(View("Save" + type, new ProductGameDetails { MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), "Select Meta tag title from List"), })); } case "HtmlBlocks": HtmlBlocks siteBlock = EntityRepository.HtmlBlocks.Where(p => p.SiteBlockId == Id).FirstOrDefault(); if (siteBlock != null) { return(View("Save" + type, new HtmlBlockDetails { SiteBlockId = siteBlock.SiteBlockId, ParentTitle = siteBlock.ParentTitle, ParentCSSClass = siteBlock.ParentCSSClass, ChildCSSClass = siteBlock.ChildCSSClass, SitePage = siteBlock.SitePage, Order = siteBlock.Order, HtmlBlockChildDetailsCollection = HtmlBlockDetails.PopulateHtmlBlockCollection(siteBlock) })); } else { var result = new HtmlBlockDetails { SiteBlockId = Guid.NewGuid(), HtmlBlockChildDetailsCollection = new List <HtmlBlockDetails.HtmlBlockChildrenDetails>() }; return(View("Save" + type, result)); } case "SEO": SEO seo = EntityRepository.SEOs.Where(p => p.SEOId == Id).FirstOrDefault(); if (seo != null) { return(View("Save" + type, new SeoDetails { SEOId = seo.SEOId, MetaTagTitle = seo.MetaTagTitle, MetaTagDescription = seo.MetaTagDescription, MetaTagKeyWords = seo.MetaTagKeyWords, SEOTags = seo.SEOTags, CustomTitle1 = seo.CustomTitle1, CustomTitle2 = seo.CustomTitle2, CustomImageTitle = seo.CustomImageTitle, CustomImageAlt = seo.CustomImageAlt, MetaRobots = seo.MetaRobots, UrlKeyWord = seo.UrlKeyWord, SEOImage = seo.SEOImage })); } else { return(View("Save" + type, new SeoDetails { })); } case "Users": Users user = EntityRepository.Users.Where(p => p.UserId == Id).FirstOrDefault(); if (user != null) { return(View("Save" + type, new UsersDetails { UserId = user.UserId, UserName = user.UserName, UserPassword = user.UserPassword, Email = user.Email, RoleId = user.RoleId })); } else { return(View("Save" + type, new UsersDetails { })); } case "Ranks": Ranks ranks = EntityRepository.Ranks.Where(p => p.RankId == Id).FirstOrDefault(); if (ranks != null) { return(View("Save" + type, new RankDetails { RankId = ranks.RankId, Name = ranks.Name, Sale = ranks.Sale })); } else { return(View("Save" + type, new RankDetails { })); } case "Customers": Customers customers = EntityRepository.Customers.Where(p => p.CustomerId == Id).FirstOrDefault(); if (customers != null) { return(View("Save" + type, new CustomersDetails { CustomerId = customers.CustomerId, Name = customers.Name, Password = customers.Password, Email = customers.Email, CarryCoinsValue = customers.CarryCoinsValue })); } else { return(View("Save" + type, new CustomersDetails { })); } case "Roles": Roles roles = EntityRepository.Roles.Where(p => p.RoleId == Id).FirstOrDefault(); if (roles != null) { return(View("Save" + type, new RolesDetails { RoleId = roles.RoleId, RoleName = roles.RoleName })); } else { return(View("Save" + type, new RolesDetails { })); } case "Article": Article article = EntityRepository.Articles.Where(p => p.ArticleId == Id).FirstOrDefault(); if (article != null) { return(View("Save" + type, new ArticleDetails { MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), article.SEO?.MetaTagTitle ?? "Select Meta tag title from List"), GamesList = new SelectList(EntityRepository.Games.Select(g => g.GameName), article?.ProductGame.GameName ?? "Select Game"), ArticleId = article.ArticleId, Title = article.Title, ShortDescription = article.ShortDescription, Description = article.Description, ReadTime = article.ReadTime, Tags = article.Tags, ImagePath = article.ImagePath, Enabled = article.Enabled, Rating = article.Rating, ArticleCreateTime = article.ArticleCreateTime, ArticleUpdateTime = article.ArticleUpdateTime, ArticlePostTime = article.ArticlePostTime })); } else { return(View("Save" + type, new ArticleDetails { MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), "Select Meta tag title from List"), GamesList = new SelectList(EntityRepository.Games.Select(g => g.GameName), "Select Game") })); } case "Orders": Orders orders = EntityRepository.Orders.Where(p => p.OrderId == Id).FirstOrDefault(); if (orders != null) { return(View("Save" + type, new OrderDetails { OrderId = orders.OrderId, Discord = orders.Discord, Comments = orders.Comment, Email = orders.Email, PaymentMethod = orders.PaymentMethod, PaymentCode = orders.PaymentCode, Total = orders.Total, OrderStatus = orders.OrderStatus, Currency = orders.Currency, CustomerIP = orders.CustomerIP, UserAgent = orders.UserAgent, OrderCreateTime = orders.OrderCreateTime, OrderUpdateTime = orders.OrderUpdateTime, EmailSended = orders.EmailSended, EmailSendTime = orders.EmailSendTime, CarryCoinsSpent = orders.CarryCoinsSpent, CarryCoinsCollected = orders.CarryCoinsCollected, ShlCharacterName = orders.OrderCustomFields.ShlCharacterName, ShlRealmName = orders.OrderCustomFields.ShlRealmName, ShlFaction = orders.OrderCustomFields.ShlFaction, ShlRegion = orders.OrderCustomFields.ShlRegion, ShlBattleTag = orders.OrderCustomFields.ShlBattleTag, Poe_CharacterName = orders.OrderCustomFields.PoeCharacterName, Poe_AccountName = orders.OrderCustomFields.PoeAccountName, Classic_CharacterName = orders.OrderCustomFields.ClassicCharacterName, Classic_RealmName = orders.OrderCustomFields.ClassicRealmName, Classic_Faction = orders.OrderCustomFields.ClassicFaction, Classic_Region = orders.OrderCustomFields.ClassicRegion, Classic_BattleTag = orders.OrderCustomFields.ClassicBattleTag })); } else { return(View("Save" + type, new OrderDetails { })); } case "ProductCategory": ProductCategory productCategory = EntityRepository.ProductCategory.Where(p => p.ProductCategoryId == Id).FirstOrDefault(); if (productCategory != null) { return(View("Save" + type, new ProductCategoryDetails { ProductCategoryId = productCategory.ProductCategoryId, MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), productCategory.SEO?.MetaTagTitle ?? "Select Meta tag title from List"), GamesList = new SelectList(EntityRepository.Games.Select(g => g.GameName), productCategory?.ProductGame.GameName ?? "Select Game"), ProductCategoryName = productCategory.ProductCategoryName, CategoryDescription = productCategory.CategoryDescription })); } else { return(View("Save" + type, new ProductCategoryDetails { MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), "Select Meta tag title from List"), GamesList = new SelectList(EntityRepository.Games.Select(g => g.GameName), "Select Game") })); } case "ProductSubCategory": ProductSubCategory productSubCategory = EntityRepository.ProductSubCategories.Where(p => p.ProductSubCategoryId == Id).FirstOrDefault(); if (productSubCategory != null) { return(View("Save" + type, new ProductSubCategoryDetails { ProductSubCategoryId = productSubCategory.ProductSubCategoryId, ProductCategoryName = productSubCategory.ProductCategoryName, CategoryDescription = productSubCategory.CategoryDescription, MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), productSubCategory.SEO?.MetaTagTitle ?? "Select Meta tag title from List"), CategoryList = new SelectList(EntityRepository.ProductCategory.Select(s => s.ProductCategoryName), productSubCategory.ProductCategory?.ProductCategoryName ?? "Select Product Category from List") })); } else { return(View("Save" + type, new ProductSubCategoryDetails { MetaTagTitleList = new SelectList(EntityRepository.SEOs.Select(s => s.MetaTagTitle), "Select Meta tag title from List"), CategoryList = new SelectList(EntityRepository.ProductCategory.Select(s => s.ProductCategoryName), "Select Product Category from List") })); } default: return(View("Admin")); } }
//foreach (ProductGameDetails.ProductCategoryDetails item in productGameDetails.ProductCategoryDetailsCollection) //{ // ProductCategory dbProductCategory = context.ProductGame.Find(productGameDetails.ProductGameId).ProductCategory.Where(p => p.ProductCategoryId == item.ProductCategoryId).FirstOrDefault(); // if (dbProductCategory != null) // { // dbProductCategory.ProductCategoryName = item.ProductCategoryName; // dbProductCategory.ProductGameId = item.ProductGameId; // dbProductCategory.CategoryDescription = item.CategoryDescription; // dbProductCategory.ProductSubCategoryId = item.ProductSubCategoryId; // dbProductCategory.CategorySeoId = item.CategorySeoId; // } //} public void SaveHtmlBlock(HtmlBlockDetails htmlBlockDetails) { HtmlBlocks dbhtmlBlocks = context.HtmlBlocks.Find(htmlBlockDetails.SiteBlockId); if (dbhtmlBlocks != null) { dbhtmlBlocks.ParentCSSClass = htmlBlockDetails.ParentCSSClass; dbhtmlBlocks.ParentTitle = htmlBlockDetails.ParentTitle; dbhtmlBlocks.ChildCSSClass = htmlBlockDetails.ChildCSSClass; dbhtmlBlocks.SitePage = htmlBlockDetails.SitePage; dbhtmlBlocks.Order = htmlBlockDetails.Order; foreach (HtmlBlockDetails.HtmlBlockChildrenDetails item in htmlBlockDetails.HtmlBlockChildDetailsCollection) { HtmlBlocksChildren dbhtmlBlocksChildren = context.HtmlBlocks.Find(htmlBlockDetails.SiteBlockId).HtmlBlocksChildren.Where(p => p.SiteBlockChildsId == item.SiteBlockChildsId).FirstOrDefault(); if (dbhtmlBlocksChildren != null) { dbhtmlBlocksChildren.Text = item.Text; dbhtmlBlocksChildren.Title = item.Title; dbhtmlBlocksChildren.Image = item.Image; dbhtmlBlocksChildren.CSSClass = item.CSSClass; dbhtmlBlocksChildren.ChildOrder = item.ChildOrder; } else { dbhtmlBlocksChildren = new HtmlBlocksChildren { }; dbhtmlBlocksChildren.SiteBlockChildsId = item.SiteBlockChildsId; dbhtmlBlocksChildren.SiteBlockId = dbhtmlBlocks.SiteBlockId; dbhtmlBlocksChildren.Text = item.Text; dbhtmlBlocksChildren.Title = item.Title; dbhtmlBlocksChildren.Image = item.Image; dbhtmlBlocksChildren.CSSClass = item.CSSClass; dbhtmlBlocksChildren.ChildOrder = item.ChildOrder; context.HtmlBlocksChildren.Add(dbhtmlBlocksChildren); } } } else { dbhtmlBlocks = new HtmlBlocks(); dbhtmlBlocks.SiteBlockId = Guid.NewGuid(); dbhtmlBlocks.ParentCSSClass = htmlBlockDetails.ParentCSSClass; dbhtmlBlocks.ParentTitle = htmlBlockDetails.ParentTitle; dbhtmlBlocks.ChildCSSClass = htmlBlockDetails.ChildCSSClass; dbhtmlBlocks.SitePage = htmlBlockDetails.SitePage; dbhtmlBlocks.Order = htmlBlockDetails.Order; if (htmlBlockDetails.HtmlBlockChildDetailsCollection != null) { foreach (HtmlBlockDetails.HtmlBlockChildrenDetails item in htmlBlockDetails.HtmlBlockChildDetailsCollection) { HtmlBlocksChildren dbhtmlBlocksChildren = new HtmlBlocksChildren { }; dbhtmlBlocksChildren.SiteBlockChildsId = Guid.NewGuid(); dbhtmlBlocksChildren.SiteBlockId = dbhtmlBlocks.SiteBlockId; dbhtmlBlocksChildren.Text = item.Text; dbhtmlBlocksChildren.Title = item.Title; dbhtmlBlocksChildren.Image = item.Image; dbhtmlBlocksChildren.CSSClass = item.CSSClass; dbhtmlBlocksChildren.ChildOrder = item.ChildOrder; context.HtmlBlocksChildren.Add(dbhtmlBlocksChildren); } } context.HtmlBlocks.Add(dbhtmlBlocks); } context.SaveChanges(); }