protected void rGridPlayer_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { PlayerDomainModel PlayerDM = new PlayerDomainModel(); PlayerPositionDomainModel PlayerPositionDM = new PlayerPositionDomainModel(); try { PlayerDM.PlayerGUID = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PlayerGUID"]; PlayerPositionDM.PlayerGUID = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PlayerGUID"]; PlayerPostionBLL.DeletePlayerPosition(PlayerPositionDM); PlayerBLL.DeletePlayer(PlayerDM); rGridPlayer.Rebind(); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); string errMethod = sf.GetMethod().Name.ToString(); // Get the current method name string errMsg = "600"; // Gotta pass something, we're retro-fitting an existing method Session["LastException"] = ex; // Throw the exception in the session variable, will be used in error page string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL Response.Redirect(url); // Go to the error page. } }
protected void rLBPlayer_SelectedIndexChanged(object sender, EventArgs e) { var strPlayerGUID = rLBPlayer.SelectedValue; Guid PlayerGuid = Guid.Parse(strPlayerGUID); hddPlayerGUID.Value = strPlayerGUID; PlayerDomainModel Player = PlayerBLL.PlayerDetail(PlayerGuid); if (Player.PlayerImage != null) { imgPlayer.DataValue = Player.PlayerImage; imgPlayer.Visible = true; imgPlayer.DataBind(); } else { imgPlayer.Visible = false; } hddSeasonID.Value = "0"; // I want all seasons hddPlayerGUID.Value = PlayerGuid.ToString(); hddPrimPosID.Value = rDDPosition.SelectedValue.ToString(); //PlayerDrafted.PlayerGUID = PlayerGuid; //BindStatsGrid(PlayerDrafted); }
public void DeletePlayer(PlayerDomainModel player) { using (CSBAAzureEntities context = new CSBAAzureEntities()) { var cPlayer = (from n in context.Players where n.PlayerGUID == player.PlayerGUID select n).FirstOrDefault(); context.Players.Remove(cPlayer); context.SaveChanges(); } }
public void UpdatePlayer(PlayerDomainModel player) { using (CSBAAzureEntities context = new CSBAAzureEntities()) { var cPlayer = context.Players.Find(player.PlayerGUID); if (cPlayer != null) { cPlayer.PlayerName = player.PlayerName; cPlayer.PlayerImage = player.PlayerImage; context.SaveChanges(); } } }
public PlayerDomainModel getPlayer(int id) { Players player = playerRepository.SingleOrDefault(m => m.playerId == id); PlayerDomainModel pDM = new PlayerDomainModel(); pDM.playerId = player.playerId; pDM.teamId = player.teamId; pDM.playerName = player.playerName; pDM.position = player.position; pDM.skill = player.skill; pDM.isPlaying = player.isPlaying; return(pDM); }
public PlayerDomainModel PlayerDetail(Guid?PlayerGUID) { PlayerDomainModel player = new PlayerDomainModel(); using (CSBAAzureEntities context = new CSBAAzureEntities()) { player = (from result in context.Players where (result.PlayerGUID == PlayerGUID) select new PlayerDomainModel { PlayerGUID = result.PlayerGUID, PlayerName = result.PlayerName, PlayerImage = result.PlayerImage }).Single(); } // Guaranteed to close the Connection return(player); }
public PlayerDomainModel InsertPlayer(PlayerDomainModel player) { using (CSBAAzureEntities context = new CSBAAzureEntities()) { var _cPlayer = new Player { PlayerName = player.PlayerName, PlayerImage = player.PlayerImage }; context.Players.Add(_cPlayer); context.SaveChanges(); // pass TeamID back to BLL player.PlayerGUID = _cPlayer.PlayerGUID; return(player); } }
public string AddEditPlayer() { PlayerViewModel vm = new PlayerViewModel(); string result = ""; //vm.playerId = 5; vm.playerName = "Testasdasd123123"; vm.position = "GK"; vm.skill = 5; vm.teamId = 2; PlayerDomainModel dm = new PlayerDomainModel(); AutoMapper.Mapper.Map(vm, dm); //result = playerBusiness.AddUpdatePlayer(dm); return(result); }
protected void rGridPlayer_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { try { PlayerDomainModel Player = new PlayerDomainModel(); rGridPlayer.DataSource = PlayerBLL.ListDraftPlayers(); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); string errMethod = sf.GetMethod().Name.ToString(); // Get the current method name string errMsg = "600"; // Gotta pass something, we're retro-fitting an existing method Session["LastException"] = ex; // Throw the exception in the session variable, will be used in error page string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL Response.Redirect(url); // Go to the error page. } }
public List <v_Stat_Hitter_ViewDomainModel> GetStats(PlayerDomainModel player) { //Create a return type Object List <v_Stat_Hitter_ViewDomainModel> list = new List <v_Stat_Hitter_ViewDomainModel>(); //Create a Context object to Connect to the database using (CSBAAzureEntities context = new CSBAAzureEntities()) { list = (from result in context.v_Stat_Hitter_View select new v_Stat_Hitter_ViewDomainModel { AB = result.AB, Agility = result.Agility, AVG = result.AVG, BB = result.BB, CS = result.CS, Doubles = result.Doubles, EBH = result.EBH, FLDP1 = result.FLDP1, FLDP2 = result.FLDP2, Hits = result.Hits, HP = result.HP, HR = result.HR, Ks = result.Ks, OBA = result.OBA, PlayerGUID = result.PlayerGUID, PlayerName = result.PlayerName, Rangep1 = result.Rangep1, RangeP2 = result.RangeP2, RBI = result.RBI, RN = result.RN, Runs = result.Runs, SB = result.SB, SeasonName = result.SeasonName, SLG = result.SLG, TB = result.TB, Triples = result.Triples }).ToList(); } // Guaranteed to close the Connection //return the list return(list); }
public ActionResult GetPlayer(int playerId) { PlayerDomainModel pDM = playerBusiness.getPlayer(playerId); PlayerSkillsDomainModel sDM = playerSkillBusiness.getPlayerSkills(pDM.skill); PlayerSkillRelationViewModel result = new PlayerSkillRelationViewModel(); PlayerViewModel pVM = new PlayerViewModel(); PlayerSkillViewModel sVM = new PlayerSkillViewModel(); AutoMapper.Mapper.Map(pDM, pVM); AutoMapper.Mapper.Map(sDM, sVM); result.PlayerVM = pVM; result.SkillVM = sVM; ViewBag.TeamList = new SelectList(getTeamVM(), "teamId", "teamName"); ViewBag.playerId = playerId; return(PartialView("EditPlayerPartial", result)); }
public string AddEditPlayer(PlayerSkillRelationViewModel vm) { //PlayerViewModel vm = new PlayerViewModel(); string result = ""; //vm.playerId = 5; //vm.playerName = "Testasdasd123123"; //vm.position = "GK"; //vm.skill = 5; //vm.teamId = 2; PlayerDomainModel dm = new PlayerDomainModel(); PlayerSkillsDomainModel skillDM = new PlayerSkillsDomainModel(); AutoMapper.Mapper.Map(vm.SkillVM, skillDM); int skillID = playerSkillBusiness.AddUpdatePlayerSkill(skillDM); AutoMapper.Mapper.Map(vm.PlayerVM, dm); result = result + " " + playerBusiness.AddUpdatePlayer(dm, skillID); return(result); }
public string AddUpdatePlayer(PlayerDomainModel dm, int skillID) { string result = ""; if (dm.playerId > 0) // Edit Player { Players player = playerRepository.SingleOrDefault(x => x.playerId == dm.playerId); if (player != null) { player.playerName = dm.playerName; player.position = dm.position; player.skill = skillID; player.teamId = dm.teamId; playerRepository.Update(player); result = "Updated"; } } else // Add Player { Players player = new Players(); player.playerName = dm.playerName; player.position = dm.position; player.skill = skillID; player.teamId = dm.teamId; playerRepository.Insert(player); result = "Added"; } return(result); }
protected void rGridPlayer_UpdIns(object sender, GridCommandEventArgs e, string Action) { try { GridEditableItem eeditedItem = e.Item as GridEditableItem; PlayerDomainModel PlayerDM = new PlayerDomainModel(); PlayerPositionDomainModel PlayerPositionDM = new PlayerPositionDomainModel(); if (Action == "Update") { PlayerDM.PlayerGUID = new Guid((eeditedItem.FindControl("lblPlayerGUID") as Label).Text.ToString()); } PlayerDM.PlayerName = (eeditedItem.FindControl("rTBPlayerName") as RadTextBox).Text.Trim(); // Deal with the image var aUpload = (eeditedItem.FindControl("AsyncUpload1") as RadAsyncUpload); if (aUpload.UploadedFiles.Count > 0) { EditableImage img = new EditableImage((MemoryStream)Context.Cache.Get(Session.SessionID + "UploadedFile")); MemoryStream s = new MemoryStream(); img.Image.Save(s, img.RawFormat); byte[] imgData = s.ToArray(); PlayerDM.PlayerImage = imgData; } else { PlayerDM.PlayerImage = null; } // Setup PlayerPositionDM if (Convert.ToInt32(((eeditedItem.FindControl("rDDPrimPos") as RadDropDownList)).SelectedValue) == 0) { PlayerPositionDM.PrimaryPositionID = null; } else { PlayerPositionDM.PrimaryPositionID = Convert.ToInt32(((eeditedItem.FindControl("rDDPrimPos") as RadDropDownList)).SelectedValue); } if (Convert.ToInt32(((eeditedItem.FindControl("rDDSecPos") as RadDropDownList)).SelectedValue) == 0) { PlayerPositionDM.SecondaryPostiionID = null; } else { PlayerPositionDM.SecondaryPostiionID = Convert.ToInt32(((eeditedItem.FindControl("rDDSecPos") as RadDropDownList)).SelectedValue); } if (Action == "Update") { PlayerPositionDM.PlayerGUID = new Guid((eeditedItem.FindControl("lblPlayerGUID") as Label).Text.ToString()); PlayerPostionBLL.DeletePlayerPosition(PlayerPositionDM); PlayerBLL.UpdatePlayer(PlayerDM); PlayerPostionBLL.UpdatePlayerPosition(PlayerPositionDM); } else if (Action == "Insert") { PlayerBLL.InsertPlayer(PlayerDM); PlayerPositionDM.PlayerGUID = PlayerDM.PlayerGUID; PlayerPostionBLL.InsertPlayerPosition(PlayerPositionDM); } //rGridPlayer.Rebind(); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); string errMethod = sf.GetMethod().Name.ToString(); // Get the current method name string errMsg = "600"; // Gotta pass something, we're retro-fitting an existing method Session["LastException"] = ex; // Throw the exception in the session variable, will be used in error page string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL Response.Redirect(url); // Go to the error page. } }
public void DeletePlayer(PlayerDomainModel player) { dal.DeletePlayer(player); }
public PlayerDomainModel InsertPlayer(PlayerDomainModel player) { return(dal.InsertPlayer(player)); }
public void UpdatePlayer(PlayerDomainModel player) { dal.UpdatePlayer(player); }
public static void HandlePitcher(List <clsPitcher> colPitchers) { PlayerBusinessLogic pBLL = new PlayerBusinessLogic(); PlayerDomainModel player = new PlayerDomainModel(); PlayerPostiionBusinessLogic ppBLL = new PlayerPostiionBusinessLogic(); PlayerPositionDomainModel playerposition = new PlayerPositionDomainModel(); StatBusinessLogic sBLL = new StatBusinessLogic(); StatDomainModel stat = new StatDomainModel(); SeasonPlayerPositionStatBusinessLogic sppsBLL = new SeasonPlayerPositionStatBusinessLogic(); SeasonPlayerPositionStatDomainModel statValue = new SeasonPlayerPositionStatDomainModel(); SeasonPlayerBusinessLogic spBLL = new SeasonPlayerBusinessLogic(); SeasonPlayerDomainModel spDM = new SeasonPlayerDomainModel(); statValue.SeasonID = C_SeasonID; statValue.PlayerGUID = player.PlayerGUID; sppsBLL.DeleteAllStatsForPlayer(statValue); foreach (clsPitcher cPitcher in colPitchers) { player.PlayerName = cPitcher.FirstName.Trim() + " " + cPitcher.LastName.Trim(); pBLL.InsertPlayer(player); playerposition.PlayerGUID = player.PlayerGUID; playerposition.PrimaryPositionID = TransformPos(cPitcher.Pos); playerposition.SecondaryPostiionID = null; ppBLL.DeletePlayerPosition(playerposition); ppBLL.InsertPlayerPosition(playerposition); spDM.PlayerGUID = player.PlayerGUID; spDM.SeasonID = C_SeasonID; spBLL.InsertSeasonPlayer(spDM); BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; foreach (FieldInfo f in cPitcher.GetType().GetFields(flags)) { Console.WriteLine("{0} = {1}", f.Name, f.GetValue(cPitcher)); System.Diagnostics.Debug.WriteLine("{0} = {1}", f.Name, f.GetValue(cPitcher)); string fieldName = _getBackingFieldName(f.Name.ToUpper()); if (fieldName != "FIRSTNAME" && fieldName != "LASTNAME" && fieldName != "PT" && fieldName != "POS") { stat.StatName = fieldName; stat.PositionTypeID = 2; // 1 = hitter stat = sBLL.InsertStat(stat); statValue.SeasonID = C_SeasonID; statValue.PlayerGUID = player.PlayerGUID; statValue.PositionID = TransformPos(cPitcher.Pos); statValue.StatID = stat.StatID; if (f.GetValue(cPitcher) == null) { statValue.StatValue = null; } else { statValue.StatValue = f.GetValue(cPitcher).ToString(); } sppsBLL.InsertStatValue(statValue); } } } }
public List <v_Stat_Hitter_ViewDomainModel> GetStats(PlayerDomainModel player) { return(dal.GetStats(player)); }