public ActionResult GameDetails(string currentGame) { ProductGame result = EntityRepository.Products.Where(p => p.ProductGame.GameShortUrl == currentGame).Select(p => p.ProductGame).FirstOrDefault(); Session["SelectedGame"] = result.GameName; return(View(result)); }
public void SaveGame(ProductGameDetails productGameDetails) { ProductGame dbproductGame = context.ProductGame.Find(productGameDetails.ProductGameId); if (dbproductGame != null) { dbproductGame.GameName = productGameDetails.GameName; dbproductGame.GameDescription = productGameDetails.GameDescription; dbproductGame.GameShortUrl = productGameDetails.GameShortUrl; dbproductGame.GameSeoId = context.SEO.Where(c => c.MetaTagTitle == productGameDetails.SelectedMetaTagTitle).Select(c => c.SEOId).FirstOrDefault(); } else { ProductGame productGame = new ProductGame() { ProductGameId = Guid.NewGuid(), GameName = productGameDetails.GameName, GameDescription = productGameDetails.GameDescription, GameShortUrl = productGameDetails.GameShortUrl, GameSeoId = context.SEO.Where(c => c.MetaTagTitle == productGameDetails.SelectedMetaTagTitle).Select(c => c.SEOId).FirstOrDefault() }; context.ProductGame.Add(productGame); } context.SaveChanges(); }
public ActionResult GameDetails(string currentGame) { ProductGame result = _context.Products.Where(p => p.ProductGame.GameName == currentGame).Select(p => p.ProductGame).FirstOrDefault(); ViewData["SelectedGame"] = result.GameName; HttpContext.Session.SetString("SelectedGame", result.GameName); return(View(result)); }
public async Task GameSave(ProductGame productgame) { bool isNew = false; DbProductGame dbproductGame = await _context.ProductGame.Where(p => p.Id == productgame.ProductGameId).FirstOrDefaultAsync(); if (dbproductGame == null) { isNew = true; dbproductGame = new DbProductGame(Guid.NewGuid()); } _mapper.Map(productgame, dbproductGame); if (isNew) { _context.ProductGame.Add(dbproductGame); return; } _context.ProductGame.Update(dbproductGame); }
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")); } }
public ViewResult CreateEdit(Guid?Id, string type, string game = null) { switch (type) { case "Product": Product prod = _context.Products.Where(p => p.ProductId == Id). Include(p => p.ProductGame). Include(p => p.ProductDescription). Include(p => p.ProductPrices). Include(p => p.ProductCategory). Include(p => p.ProductSubCategory). Include(p => p.ProductSeo).FirstOrDefault(); ProductDetails productDetails = new ProductDetails(); if (prod != null) { productDetails = _mapper.Map <Product, ProductDetails>(prod); productDetails = _mapper.Map(prod.ProductDescription, productDetails); productDetails = _mapper.Map(prod.ProductPrices.FirstOrDefault(), productDetails); //productDetails = _mapper.Map<ProductDetails>(prod); //productDetails = _mapper.Map<ProductDetails>(prod.ProductDescription);1 //productDetails = _mapper.Map<ProductDetails>(prod.ProductPrices.FirstOrDefault()); productDetails.GamesList = new SelectList(_context.ProductGames.Select(g => g.GameName), prod.ProductGame?.GameName ?? "Select Game"); productDetails.CategoriesList = new SelectList(_context.ProductCategories.Where(c => c.ProductGame.GameName == prod.ProductGame.GameName).Select(c => c.ProductCategoryName), prod.ProductCategory?.ProductCategoryName ?? "Select Category"); productDetails.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), prod.ProductSeo?.MetaTagTitle ?? "Select Meta tag title"); //TODO:ProductSubCategory productDetails.SubCategoriesList = new SelectList(_context.ProductSubCategories.Select(sc => sc.ProductCategoryName), prod.ProductSubCategory?.ProductCategoryName ?? "Select Product Sub Category Name"); return(View("Save" + type, productDetails)); } else { //TODO: Вытащи все название игр,категорий и метатэгов productDetails.GamesList = new SelectList(_context.ProductGames.Select(g => g.GameName), prod.ProductGame.GameName ?? "Select Game"); productDetails.CategoriesList = new SelectList(_context.ProductCategories.Where(c => c.ProductGame.GameName == prod.ProductGame.GameName).Select(c => c.ProductCategoryName), prod.ProductCategory.ProductCategoryName ?? "Select Category"); productDetails.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), prod.ProductSeo.MetaTagTitle ?? "Select Meta tag title"); return(View("Save" + type, productDetails)); } case "TemplateOption": TemplateOption templateOption = _context.TemplateOptions.Where(p => p.OptionId == Id).Include(p => p.TempOptionParams).FirstOrDefault(); TemplateOptionDetails templateOptionDetails = new TemplateOptionDetails(); if (templateOption != null) { templateOptionDetails = _mapper.Map <TemplateOption, TemplateOptionDetails>(templateOption); return(View("Save" + type, templateOption)); } else { return(View("Save" + type, templateOption)); } case "ProductGame": ProductGame productGame = _context.ProductGames.Where(p => p.ProductGameId == Id).FirstOrDefault(); if (productGame != null) { return(View("Save" + type, productGame)); } else { return(View("Save" + type, productGame)); { ViewBag.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), "Select Meta tag title from List"); }; } case "HtmlBlocks": HtmlBlock siteBlock = _context.HtmlBlocks.Where(p => p.SiteBlockId == Id).Include(p => p.HtmlBlocksChildren).FirstOrDefault(); if (siteBlock != null) { return(View("Save" + type, siteBlock)); } else { //TODO: Children //var result = new HtmlBlock { SiteBlockId = Guid.NewGuid(), HtmlBlocksChildren = new List<HtmlBlock.HtmlBlocksChildren>() }; return(View("Save" + type, siteBlock)); } case "SEO": Seo seo = _context.Seos.Where(p => p.Seoid == Id).FirstOrDefault(); if (seo != null) { return(View("Save" + type, seo)); } else { return(View("Save" + type, seo)); } case "Users": User user = _context.Users.Where(p => p.UserId == Id).FirstOrDefault(); if (user != null) { return(View("Save" + type, user)); } else { return(View("Save" + type, user)); } case "Ranks": Rank ranks = _context.Ranks.Where(p => p.RankId == Id).FirstOrDefault(); if (ranks != null) { return(View("Save" + type, ranks)); } else { return(View("Save" + type, ranks)); } case "Customers": Customer customers = _context.Customers.Where(p => p.CustomerId == Id).FirstOrDefault(); if (customers != null) { return(View("Save" + type, customers)); } else { return(View("Save" + type, customers)); } case "Roles": Role roles = _context.Roles.Where(p => p.RoleId == Id).FirstOrDefault(); if (roles != null) { return(View("Save" + type, roles)); } else { return(View("Save" + type, roles)); } case "Article": Article article = _context.Articles.Where(p => p.ArticleId == Id).FirstOrDefault(); if (article != null) { ViewBag.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), "Select Meta tag title from List"); ViewBag.GamesList = new SelectList(_context.ProductGames.Select(g => g.GameName), "Select Game"); return(View("Save" + type, article)); } else { return(View("Save" + type, article)); { ViewBag.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), "Select Meta tag title from List"); ViewBag.GamesList = new SelectList(_context.ProductGames.Select(g => g.GameName), "Select Game"); }; } case "Orders": Order orders = _context.Orders.Where(p => p.OrderId == Id).FirstOrDefault(); if (orders != null) { return(View("Save" + type, orders)); } else { return(View("Save" + type, orders)); } case "ProductCategory": ProductCategory productCategory = _context.ProductCategories.Where(p => p.ProductCategoryId == Id).FirstOrDefault(); if (productCategory != null) { ViewBag.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), "Select Meta tag title from List"); ViewBag.GamesList = new SelectList(_context.ProductGames.Select(g => g.GameName), "Select Game"); return(View("Save" + type, productCategory)); } else { return(View("Save" + type, productCategory)); { ViewBag.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), "Select Meta tag title from List"); ViewBag.GamesList = new SelectList(_context.ProductGames.Select(g => g.GameName), "Select Game"); }; } case "ProductSubCategory": ProductSubCategory productSubCategory = _context.ProductSubCategories.Where(p => p.ProductSubCategoryId == Id).FirstOrDefault(); if (productSubCategory != null) { return(View("Save" + type, productSubCategory)); } else { return(View("Save" + type, productSubCategory)); { ViewBag.MetaTagTitleList = new SelectList(_context.Seos.Select(s => s.MetaTagTitle), "Select Meta tag title from List"); ViewBag.CategoryList = new SelectList(_context.ProductCategories.Select(s => s.ProductCategoryName), "Select Product Category from List"); }; } default: return(View("Admin")); } }