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 SaveGame(ProductGameDetails productGameDetails) { if (ModelState.IsValid) { EntityRepository.SaveGame(productGameDetails); TempData["message"] = string.Format("Product Game Details has been saved"); return(RedirectToAction("List", new { type = "ProductGame" })); } else { return(RedirectToAction("List", new { type = "ProductGame" })); } }