// // GET: /PlayerSettingAccountDefault/Edit/5 public ActionResult Edit(string id) { try { if (Session["UserAccountID"] == null) { return(RedirectToAction("Validate", "Login")); } User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) { ViewData["txtIsAdmin"] = "true"; } else { ViewData["txtIsAdmin"] = "false"; } bool isid = true; try { int x = Convert.ToInt32(id); } catch { isid = false; } PlayerSettingAccountDefault accountdefault = new PlayerSettingAccountDefault(); IPlayerSettingSystemDefaultRepository systemdefaultrep = new EntityPlayerSettingSystemDefaultRepository(); if (isid) { IPlayerSettingAccountDefaultRepository accountdefaultrep = new EntityPlayerSettingAccountDefaultRepository(); accountdefault = accountdefaultrep.GetByPlayerSettingAccountDefaultID(Convert.ToInt32(id)); } else { PlayerSettingSystemDefault systemdefault = systemdefaultrep.GetByPlayerSettingName(id); if (systemdefault != null) { accountdefault.PlayerSettingAccountDefaultID = 0; accountdefault.AccountID = Convert.ToInt32(Session["UserAccountID"]); accountdefault.PlayerSettingName = systemdefault.PlayerSettingName; accountdefault.PlayerSettingTypeID = systemdefault.PlayerSettingTypeID; accountdefault.PlayerSettingAccountDefaultValue = systemdefault.PlayerSettingSystemDefaultValue; } } IPlayerSettingTypeRepository typerep = new EntityPlayerSettingTypeRepository(); ViewData["PlayerSettingTypeName"] = typerep.GetPlayerSettingType(accountdefault.PlayerSettingTypeID).PlayerSettingTypeName; ViewData["PlayerSettingDescription"] = systemdefaultrep.GetByPlayerSettingName(accountdefault.PlayerSettingName).PlayerSettingDescription; ViewData["ValidationMessage"] = String.Empty; return(View(accountdefault)); } catch (Exception ex) { Helpers.SetupApplicationError("PlayerSettingAccountDefault", "Edit", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }
// // GET: /PlayerSetting/EditSetting/5 public ActionResult EditSetting(string id) { try { if (Session["UserAccountID"] == null) { return(RedirectToAction("Validate", "Login")); } User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) { ViewData["txtIsAdmin"] = "true"; } else { ViewData["txtIsAdmin"] = "false"; } bool isid = true; try { int x = Convert.ToInt32(id); } catch { isid = false; } PlayerSetting playersetting = new PlayerSetting(); IPlayerSettingSystemDefaultRepository systemdefaultrep = new EntityPlayerSettingSystemDefaultRepository(); IPlayerSettingAccountDefaultRepository accountdefaultrep = new EntityPlayerSettingAccountDefaultRepository(); if (isid) { IPlayerSettingRepository playersettingrep = new EntityPlayerSettingRepository(); playersetting = playersettingrep.GetByPlayerSettingID(Convert.ToInt32(id)); } else { // Get the system default values PlayerSettingSystemDefault systemdefault = systemdefaultrep.GetByPlayerSettingName(id); if (systemdefault != null) { playersetting.PlayerSettingID = 0; playersetting.PlayerID = Convert.ToInt32(Session["ConfigurePlayerID"]); playersetting.PlayerSettingName = systemdefault.PlayerSettingName; playersetting.PlayerSettingTypeID = systemdefault.PlayerSettingTypeID; playersetting.PlayerSettingValue = systemdefault.PlayerSettingSystemDefaultValue; } // Override with any existing account defaults PlayerSettingAccountDefault accountdefault = accountdefaultrep.GetByPlayerSettingName(Convert.ToInt32(Session["UserAccountID"]), id); if (accountdefault != null) { playersetting.PlayerSettingID = 0; playersetting.PlayerID = Convert.ToInt32(Session["ConfigurePlayerID"]); playersetting.PlayerSettingName = accountdefault.PlayerSettingName; playersetting.PlayerSettingTypeID = accountdefault.PlayerSettingTypeID; playersetting.PlayerSettingValue = accountdefault.PlayerSettingAccountDefaultValue; } } IPlayerSettingTypeRepository typerep = new EntityPlayerSettingTypeRepository(); ViewData["PlayerSettingTypeName"] = typerep.GetPlayerSettingType(playersetting.PlayerSettingTypeID).PlayerSettingTypeName; ViewData["PlayerSettingDescription"] = systemdefaultrep.GetByPlayerSettingName(playersetting.PlayerSettingName).PlayerSettingDescription; IPlayerRepository playerrep = new EntityPlayerRepository(); Player player = playerrep.GetPlayer(Convert.ToInt32(Session["ConfigurePlayerID"])); ViewData["PlayerID"] = player.PlayerID; ViewData["PlayerName"] = player.PlayerName; ViewData["ValidationMessage"] = String.Empty; return(View(playersetting)); } catch (Exception ex) { Helpers.SetupApplicationError("PlayerSetting", "EditSetting", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }