private MatchLineupDTO GetLineup(AutocompleteTextBox actbPlayer, int countryId, int shirtNum, int?lineupId, bool isSubstitute, bool isHomeTeamPlayer, int flags) { int playerId = 0; if (!actbPlayer.Value.IsEmpty() && !actbPlayer.Value.Equals("0")) { playerId = int.Parse(actbPlayer.Value); } else { if (actbPlayer.Text.Length > 0) { string fName = null; string lName = null; int spaceIndex = actbPlayer.Text.IndexOf(' '); if (spaceIndex > 1) { fName = actbPlayer.Text.Substring(0, spaceIndex); lName = actbPlayer.Text.Substring(spaceIndex + 1); } else { lName = actbPlayer.Text; } PlayerDTO newPlayer = new PlayerDTO() { First_Name = fName, Last_Name = lName, RequiresReview = true, Country_Id = countryId }; playerId = new PlayerDTOHelper().SaveToDB(newPlayer); } } MatchLineupDTO hpml = new MatchLineupDTO { IsHomeTeamPlayer = isHomeTeamPlayer, Match_Id = DataItem.Match_Id, IsSubstitute = isSubstitute, Player_Id = playerId, ShirtNum = shirtNum, Flags = flags }; if (lineupId.HasValue) { hpml.MatchLineup_Id = lineupId.Value; } return(hpml); }
protected void Page_Load(object sender, EventArgs e) { Page.ClientScript.RegisterClientScriptInclude(Constants.Paths.ColorboxKey, Page.ResolveClientUrl(Constants.Paths.ColorboxPath)); if (!IsPostBack) { if (Request[Constants.QueryParam.PlayerId].Length > 0) { int playerId = int.Parse(Request[Constants.QueryParam.PlayerId]); DataItem = new PlayerDTOHelper().GetPlayer(playerId); string thumbPath = "\\thumb\\"; IEnumerable <MultimediaDTO> playerLogos = DataItem.Multimedia.Where(m => m.MultimediaSubType_CD == Constants.DB.MutlimediaSubTypes.PlayerLogo); if (playerLogos.Count() > 0) { MultimediaDTO logo = playerLogos.OrderByDescending(pl => pl.Multimedia_ID).First(); iPlayerLogo.ImageUrl = PathHelper.GetWebPath(this, Constants.Paths.MutlimediaWebRoot, logo.FilePath + thumbPath, logo.FileName); } else { iPlayerLogo.ImageUrl = ResolveClientUrl("~/WebApplication/images/nofoto.jpg"); } mlpLast20.PlayerId = playerId; mlpLast20.DataSource = DataItem.Matches.OrderByDescending(m => m.Date).Take(20); mlpLast20.DataBind(); IEnumerable <MatchDTO> nationalTeamMatches = DataItem.Matches.Where(m => m.IsNationalTeamMatch); mlpSBU.PlayerId = playerId; mlpSBU.DataSource = nationalTeamMatches.OrderByDescending(m => m.Date); mlpSBU.DataBind(); IEnumerable <MatchDTO> europcupMatches = DataItem.Matches.Where(m => !m.IsNationalTeamMatch); mlpClub.PlayerId = playerId; mlpClub.DataSource = europcupMatches.OrderByDescending(m => m.Date); mlpClub.DataBind(); NationalTeamMatchesCount = nationalTeamMatches.Count(); EuropcupsMatchesCount = europcupMatches.Count(); PhotoCount = DataItem.Multimedia.Count(mm => mm.MultimediaSubType_CD == Constants.DB.MutlimediaSubTypes.MatchPhoto); VideoCount = DataItem.Multimedia.Count(mm => mm.MultimediaType_CD == Constants.DB.MutlimediaTypes.Video); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlMultimediaSubType.Items.Add(new ListItem(Constants.UI.MutlimediaSubTypes.ClubLogo, Constants.DB.MutlimediaSubTypes.ClubLogo)); ddlMultimediaSubType.Items.Add(new ListItem(Constants.UI.MutlimediaSubTypes.NationalTeamLogo, Constants.DB.MutlimediaSubTypes.NationalTeamLogo)); ddlMultimediaSubType.Items.Add(new ListItem(Constants.UI.MutlimediaSubTypes.PlayerLogo, Constants.DB.MutlimediaSubTypes.PlayerLogo)); ddlMultimediaSubType.Items.Add(new ListItem(Constants.UI.MutlimediaSubTypes.MatchPhoto, Constants.DB.MutlimediaSubTypes.MatchPhoto)); ddlMultimediaSubType.Items.Add(new ListItem(Constants.UI.MutlimediaSubTypes.MatchVideo, Constants.DB.MutlimediaSubTypes.MatchVideo)); ddlMultimediaSubType.SelectedIndex = 3; ddlMultimediaSubType_SelectedIndexChanged(ddlMultimediaSubType, new EventArgs()); cbl1.Items.Add(new ListItem(Constants.UI.MultimediaTags.BadQuality, Constants.DB.MultimediaTags.BadQuality.ToString())); cbl1.Items.Add(new ListItem(Constants.UI.MultimediaTags.AwayTeamPhoto, Constants.DB.MultimediaTags.AwayTeamPhoto.ToString())); cbl1.Items.Add(new ListItem(Constants.UI.MultimediaTags.HomeTeamPhoto, Constants.DB.MultimediaTags.HomeTeamPhoto.ToString())); if (!string.IsNullOrEmpty(Request["id"])) { int multimediaId = MMId; if (multimediaId > 0) { btnDelete.Visible = true; using (UaFootball_DBDataContext db = DBManager.GetDB()) { UaFDatabase.Multimedia mm = db.Multimedias.SingleOrDefault(m => m.Multimedia_ID == multimediaId); if (mm != null) { ddlMultimediaSubType.Enabled = false; afuUploader.Enabled = false; hfFileName.Value = mm.FileName; ddlMultimediaSubType.SelectedValue = mm.MultimediaSubType_CD; ddlMultimediaSubType_SelectedIndexChanged(ddlMultimediaSubType, new EventArgs()); List <MultimediaTag> tags = db.MultimediaTags.Where(m => m.Multimedia_ID == multimediaId).ToList(); if (tags.Count > 0) { List <MultimediaTagDTO> tagsToBind = tags.Select(t => new MultimediaTagDTO { Club_ID = t.Club_ID, MatchEvent_ID = t.MatchEvent_ID, Match_ID = t.Match_ID, NationalTeam_ID = t.NationalTeam_ID, Player_ID = t.Player_ID, tmpId = t.MultimediaTag_ID, MultimediaTag_ID = t.MultimediaTag_ID }).ToList(); foreach (MultimediaTagDTO mt in tagsToBind) { if (mt.Match_ID.HasValue) { mt.Type = _tagTypeGame; vwMatch match = db.vwMatches.SingleOrDefault(m => m.Match_ID == mt.Match_ID.Value); mt.Description = UIHelper.FormatMatch(match); } if (mt.Player_ID.HasValue) { mt.Type = _tagTypePlayer; PlayerDTO player = new PlayerDTOHelper().GetPlayer(mt.Player_ID.Value); mt.Description = UIHelper.FormatName(player); } if (mt.MatchEvent_ID.HasValue) { mt.Type = _tagTypeEvent; DataLoadOptions opt = new DataLoadOptions(); opt.LoadWith <MatchEvent>(m => m.Player1); UaFDatabase.MatchEvent mEvent = db.MatchEvents.SingleOrDefault(m => m.MatchEvent_Id == mt.MatchEvent_ID.Value); mt.Description = string.Format("{0} мин - {1} - {2}", mEvent.Minute, UIHelper.EventCodeMap[mEvent.Event_Cd], FormatName(mEvent.Player.First_Name, mEvent.Player.Last_Name, mEvent.Player.Display_Name, mEvent.Player.Country_Id)); } if (mt.Club_ID.HasValue) { mt.Type = _tagTypeClub; ClubDTO club = new ClubDTOHelper().GetFromDB(mt.Club_ID.Value); mt.Description = string.Format("{0} ({1})", club.Club_Name, club.City_Name); } if (mt.NationalTeam_ID.HasValue) { mt.Type = _tagTypeNatTeam; mt.Description = "Украина"; } } TagsCache.AddRange(tagsToBind); rptTags.DataSource = tagsToBind; rptTags.DataBind(); } if (mm.Flags.HasValue) { if (mm.Flags > 0) { foreach (ListItem li in cbl1.Items) { if ((long.Parse(li.Value) & mm.Flags.Value) > 0) { li.Selected = true; } } } } tbAuthor.Text = mm.Author; tbSource.Text = mm.Source; tbDescription.Text = mm.Description; tbPhotoDate.Text = FormatDate(mm.DateTaken); if (mm.MultimediaType_CD == Constants.DB.MutlimediaTypes.Image) { imgMultimedia.ImageUrl = PathHelper.GetWebPath(this, Constants.Paths.MutlimediaWebRoot, mm.FilePath, mm.FileName); } } } } } } }