protected void btnOK_Click(object sender, EventArgs e) { // 2、在数据库表中添加球员数据 Team model = new Team(); model.TeamName = txtTeamName.Text; model.DivisionId = Convert.ToInt32(ddlDivision.SelectedValue); //调用方法 int result = tm.Add(model); //判断返回结果 if (result > 0) { ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('添加球队成功!');window.location.href='TeamList.aspx'</script>"); } else { if (result == -1) { ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('球队已存在!')</script>"); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('添加球队失败!')</script>"); } } }
static void Main(string[] args) { var player1 = new Player { Id = 1, Name = "Mike", Number = 13, Points = 5, }; var team = new TeamManager(); team.Add(player1); team.Delete(player1); }
/// <summary> /// Saving new Team to database /// </summary> /// <param name="user"></param> /// <param name="teamManager"></param> /// <param name="stadiumManager"></param> /// <param name="playerManager"></param> /// <param name="playerSkillManager"></param> /// <param name="nationManager"></param> /// <param name="coachManager"></param> /// <param name="coachSkillManager"></param> /// <returns></returns> public static Team CreateFinishedTeam( User user, TeamManager teamManager, StadiumManager stadiumManager, PlayerManager playerManager, PlayerSkillManager playerSkillManager, NationManager nationManager // CoachManager coachManager, //CoachSkillManager coachSkillManager ) { Team team = CreateTeam(user); // coachSkillManager.Add(team.Coach.CoachSkill); //coachSkillManager.Save(); // coachManager.Add(team.Coach); //coachManager.Save(); stadiumManager.Add(team.Stadium); stadiumManager.Save(); teamManager.Add(team); teamManager.Save(); team.Players = PlayerMethod.CreatePlayers().ToList(); foreach (Player player in team.Players) { nationManager.Add(player.Nation); nationManager.Save(); playerSkillManager.Add(player.PlayerSkill); playerSkillManager.Save(); playerManager.Add(player); playerManager.Save(); } teamManager.Save(); return(team); }
public int Add(Team Team) { return(pm.Add(Team)); }
private void UnitRelease(Vector3 target) { List <RaycastResult> castHits = new List <RaycastResult>(); PointerEventData eventPoint = new PointerEventData(eventSystem); eventPoint.position = target; gRayCaster.Raycast(eventPoint, castHits); if (castHits.Count > 0) { for (int i = 0; i < castHits.Count; i++) { if (castHits[i].gameObject.CompareTag("InventoryBoard")) { // place into inventory, remove from board list if (originTile != null) { inventoryManager.AddCard(originTile.heldUnit.instanceNumber); teamManager.Remove(originTile.heldUnit.gameObject); Destroy(originTile.heldUnit.gameObject); originTile.heldUnit = null; originTile.CenterUnit(); originTile = null; fromTile = false; holdingUnit = false; } else { DropInventoryUnit(); } } } } RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(target); if (Physics.Raycast(ray, out hit, 100.0f, castMask)) { if (fromTile) { Tile targetTile = hit.transform.gameObject.GetComponent <Tile>(); if (targetTile.UnitPlace(originTile.heldUnit, originTile) != true) { // snap unit back DropUnit(); } else { holdingUnit = false; fromTile = false; } } else if (!fromTile && holdingUnit) { Tile targetTile = hit.transform.gameObject.GetComponent <Tile>(); if (targetTile.heldUnit != null && targetTile.isYours) { // swap unit with held unit inventoryManager.AddCard(targetTile.heldUnit.instanceNumber); teamManager.Remove(targetTile.heldUnit.gameObject); Destroy(targetTile.heldUnit.gameObject); teamManager.Add(heldUnit); targetTile.heldUnit = heldUnit; targetTile.CenterUnit(); holdingUnit = false; heldUnit = null; } else if (teamManager.CheckSpot()) { // place unit if (targetTile.UnitPlace(heldUnit) != true) { // snap unit back into inventory DropInventoryUnit(); } else { teamManager.Add(heldUnit); holdingUnit = false; heldUnit = null; } } else { // snap unit back into inventory and give feedback that team is full DropInventoryUnit(); } } } else { if (fromTile) { DropUnit(); } else if (heldUnit != null) { DropInventoryUnit(); } } }
public string Post([FromBody] Team entity) { return(JsonConvert.SerializeObject(_teamService.Add(entity))); //return "ahhaha"; }