Exemplo n.º 1
0
 public static string GetPlayerNameLink(Player player)
 {
     string link = HttpContext.Current.Request.Url.AbsoluteUri.IndexOf('?') < 0
         ? HttpContext.Current.Request.Url.AbsoluteUri
         : HttpContext.Current.Request.Url.AbsoluteUri
             .Remove(HttpContext.Current.Request.Url.AbsoluteUri.IndexOf("?"));
     return string.Format("<a href='{0}?userId={1}'>{2}</a>",
         link,
         player.Id,
         GetPlayerName(player));
 }
Exemplo n.º 2
0
 private void AddRow(Match m, Player p, TrambambuleDBContextDataContext context)
 {
     TableRow row = new TableRow();
     row.Cells.Add(new TableCell()
     {
         HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center,
         Text = m.Timestamp.ToString("dd-MM-yyyy HH:mm:ss")
     });
     //row.Cells.Add(new TableCell()
     //{
     //    HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center,
     //    Text = "ATAK<br/>OBRONA"
     //});
     row.Cells.Add(new TableCell()
     {
         HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center,
         Text = GetTeamString(m.TeamMatches[0], p, context)
     });
     row.Cells.Add(new TableCell()
     {
         HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center,
         Text = m.TeamMatches[0].GoalsScored + " : " + m.TeamMatches[0].GoalsLost
     });
     row.Cells.Add(new TableCell()
     {
         HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center,
         Text = GetTeamString(m.TeamMatches[1], p, context)
     });
     if (p != null)
     {
         Common.EResult result = (Common.EResult)Enum.Parse(typeof(Common.EResult),
             m.TeamMatches.First(x => x.TeamMatchPlayers.Any(z => z.PlayerId == p.Id)).Result.ToString());
         switch (result)
         {
             case Common.EResult.Loose:
                 //row.CssClass = "loose";
                 row.Cells[2].ForeColor = Color.Red;
                 break;
             case Common.EResult.Win:
                 //row.CssClass = "win";
                 row.Cells[2].ForeColor = Color.Green;
                 break;
             case Common.EResult.Draw:
                 //row.CssClass = "draw";
                 row.Cells[2].ForeColor = Color.Blue;
                 break;
         }
     }
     tblResults.Rows.Add(row);
 }
        protected void btnAddNewPlayer_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string firstName = txtNewPlayerFirstName.Text.Trim();
                string lastName = txtNewPlayerLastName.Text.Trim();
                if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName) && firstName.Length > 0 && firstName.Length <= 100 && lastName.Length > 0 && lastName.Length <= 100)
                {
                    int location = int.Parse(ddlLocation.SelectedValue);
                    string nick = (firstName.Length < 2 ? "Jakiś" : firstName.Substring(0, 2)) + (lastName.Length < 2 ? "Pseudonim" : lastName.Substring(0, 2));
                    using (TrambambuleDBContextDataContext context = new TrambambuleDBContextDataContext())
                    {
                        try
                        {
                            Player p = new Player();
                            p.FirstName = firstName;
                            p.LastName = lastName;
                            p.Location = location;
                            p.Nickname = nick;
                            p.Timestamp = DateTime.Now;

                            context.Players.InsertOnSubmit(p);
                            context.SubmitChanges();

                            Cache.Remove(DataAccess.PlayersListCacheName);
                            Cache.Remove(DataAccess.PlayersNamesAndSurnamesWithoutPolishCharsCacheName);
                            Cache.Remove(DataAccess.PlayersAchievementsCacheName);
                            Cache.Remove(DataAccess.AllAchievementsCacheName);
                            Cache.Remove(DataAccess.OverallStatsCacheName);

                            new AchievementsService(new List<Player>() { p }).RecalculateAchievements(true);

                            litStatus.Text = "<div class=\"validator\">Użytkownik został dodany</div>";
                            txtNewPlayerFirstName.Text = "";
                            txtNewPlayerLastName.Text = "";
                            ddlLocation.SelectedIndex = 0;
                        }
                        catch { litStatus.Text = "<div class=\"validator\">Wystąpił błąd podczas dodawania nowego użytkownika</div>"; }
                    }
                }
            }
        }
Exemplo n.º 4
0
 public static bool CompareNames(Player p, string prefix)
 {
     return CreateTextCompareString(p.FirstName + p.LastName)
         .Contains(CreateTextCompareString(prefix));
 }
 partial void DeletePlayer(Player instance);
 partial void UpdatePlayer(Player instance);
 partial void InsertPlayer(Player instance);
Exemplo n.º 8
0
        private string GetTeamString(TeamMatch tm, Player p, TrambambuleDBContextDataContext context)
        {
            var offence = tm.TeamMatchPlayers.First(x => x.Position == (byte)Common.EPosition.Offence);
            var defence = tm.TeamMatchPlayers.First(x => x.Position == (byte)Common.EPosition.Defence);

            int offenceRatingChange = 0;
            int defenceRatingChange = 0;
            if (offence.RatingChange.HasValue)
                offenceRatingChange = (int)offence.RatingChange.Value;
            else
                offenceRatingChange = (int)Math.Round((double)(offence.Rating - PlayerHelper.INITIAL_RATING), 0);

            if (defence.RatingChange.HasValue)
                defenceRatingChange = (int)defence.RatingChange.Value;
            else
                defenceRatingChange = (int)Math.Round((double)(defence.Rating - PlayerHelper.INITIAL_RATING), 0);

            return string.Format("{0} ({2})<br/>{1} ({3})",
                GetPlayerNameString(offence.Player, p),
                GetPlayerNameString(defence.Player, p),
                GetRatingChangeString(offenceRatingChange),
                GetRatingChangeString(defenceRatingChange));
        }
Exemplo n.º 9
0
 private string GetPlayerNameString(Player tmp, Player p)
 {
     if (p == null)
         return PlayerHelper.GetPlayerNameLink(tmp);
     else
         return tmp.Id == p.Id
             ? ("<b>" + PlayerHelper.GetPlayerNameLink(tmp) + "</b>")
             : PlayerHelper.GetPlayerNameLink(tmp);
 }
Exemplo n.º 10
0
 public static string GetPlayerName(Player player)
 {
     return player.FirstName + " " + player.LastName;
 }