public List <Match> GetMatchByTeamID(int tID) { var cs = Services.ContentService; List <Match> matchlist = new List <Match>(); var matches = cs.GetById(tID).Descendants().Where(t => t.ContentType.Alias.Equals("match")); foreach (var match in matches) { var m = new Match(); m.matchId = match.Id; m.matchAddress = (match.Properties["matchAddress"].Value != null) ? match.Properties["matchAddress"].Value.ToString() : "Match Address"; m.matchCity = (match.Properties["matchCity"].Value != null) ? match.Properties["matchCity"].Value.ToString() : "Match City"; m.matchStartDateTime = (match.Properties["matchStartDateTime"].Value != null) ? match.Properties["matchStartDateTime"].Value.ToString() : "Match Start DateTime"; m.opponent = (match.Properties["opponent"].Value != null) ? match.Properties["opponent"].Value.ToString() : "Opponent"; m.homeGoal = int.Parse((match.Properties["homeGoal"].Value != null) ? match.Properties["homeGoal"].Value.ToString() : "0"); m.opponentGoal = int.Parse((match.Properties["opponentGoal"].Value != null) ? match.Properties["opponentGoal"].Value.ToString() : "0"); var matchStatus = (match.Properties["status"].Value != null) ? match.Properties["status"].Value.ToString() : "Status"; m.status = Umbraco.GetPreValueAsString(int.Parse(matchStatus)); matchlist.Add(m); } return(matchlist); }
public List <Team> GetTeams(int cID) { var cs = Services.ContentService; List <Team> teamlist = new List <Team>(); var teams = cs.GetById(cID).Descendants().Where(t => t.ContentType.Alias.Equals("team")); foreach (var team in teams) { var t = new Team(); t.teamId = team.Id; t.teamName = (team.Properties["teamName"].Value != null) ? team.Properties["teamName"].Value.ToString() : "Team name"; var sportsType = (team.Properties["teamSport"].Value != null) ? team.Properties["teamSport"].Value.ToString() : "teamSport"; t.teamSport = Umbraco.GetPreValueAsString(int.Parse(sportsType)); teamlist.Add(t); } return(teamlist); }
public ActionResult RenderHome() { IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); int mapImageId = homePage.GetPropertyValue <int>("map"); string mapImageUrl = Umbraco.Media(mapImageId).Url; List <AirConditioner> airConditioners = new List <AirConditioner>(); ArchetypeModel airConditionersConfigs = homePage.GetPropertyValue <ArchetypeModel>("airConditioners"); foreach (ArchetypeFieldsetModel fieldset in airConditionersConfigs) { Guid id = fieldset.Id; string name = fieldset.GetValue <string>("name"); int maxTemperature = fieldset.GetValue <int>("maxTemperature"); int minTemperature = fieldset.GetValue <int>("minTemperature"); var temperatureScaleId = fieldset.GetValue <int>("temperatureScale"); string temperatureScale = Umbraco.GetPreValueAsString(temperatureScaleId); IPublishedContent image = fieldset.GetValue <IPublishedContent>("image"); string imageUrl = image.Url; var isVertical = int.Parse(image.GetPropertyValue("umbracoHeight").ToString()) > int.Parse(image.GetPropertyValue("umbracoWidth").ToString()); string positionX = fieldset.GetValue <string>("positionX"); string positionY = fieldset.GetValue <string>("positionY"); string width = fieldset.GetValue <string>("width"); string height = fieldset.GetValue <string>("height"); airConditioners.Add(new AirConditioner(id, name, maxTemperature, minTemperature, temperatureScale, imageUrl, positionX, positionY, width, height, isVertical)); } HomeModel homeModel = new HomeModel(mapImageUrl, airConditioners); return(PartialView(GetPartialView("_Home"), homeModel)); }
public override bool Validate(IFieldValues fieldValues) { var prevalueIdForAllOrAny = fieldValues.GetValue <int>("MatchType"); var allOrAny = Umbraco.GetPreValueAsString(prevalueIdForAllOrAny); var membership = new MembershipHelper(UmbracoContext.Current); var groups = fieldValues.GetValue("Group").Split(','); bool success; if (allOrAny == "All") { success = groups.All(c => Roles.IsUserInRole(membership.CurrentUserName, c)); } else { success = groups.Any(c => Roles.IsUserInRole(membership.CurrentUserName, c)); } return(membership.IsLoggedIn() && success); }
public List <teams> GetTeams(int clubId) { var cs = Services.ContentService; var teams = cs.GetChildren(clubId); var c = cs.GetById(clubId); var AT = new teams(); List <teams> AllTeams = new List <teams>(); foreach (var team in teams) { if (team.ContentTypeId == 1074) { var t = new teams(); t.id = team.Id; t.name = team.Name; t.clubName = c.Name; var sport = (team.Properties["typeOfSport"].Value.ToString() != null) ? this.GetSport(team.Properties["typeOfSport"].Value.ToString()) : null; t.sport = sport; var gender = (team.Properties["typeOfGender"].Value != null) ? team.Properties["typeOfGender"].Value.ToString() : null; try { t.gender = Umbraco.GetPreValueAsString(int.Parse(gender)); } catch { t.gender = ""; } t.coach = (team.Properties["teamManager"].Value != null) ? this.GetManager(team.Properties["teamManager"].Value.ToString()) : null; AllTeams.Add(t); } } return(AllTeams); }
public List <Club> GetAllClubs(int rootID) { var cs = Services.ContentService; List <Club> allClubs = new List <Club>(); var clubs = cs.GetById(rootID).Children().Where(t => t.ContentType.Alias.Equals("Club")); foreach (var club in clubs) { var c = new Club(); c.clubId = club.Id; c.clubName = (club.Properties["clubName"].Value != null) ? club.Properties["clubName"].Value.ToString() : "No club name found"; c.clubAddress = (club.Properties["clubAddress"].Value != null) ? club.Properties["clubAddress"].Value.ToString() : "No club address found"; c.clubCity = (club.Properties["clubCity"].Value != null) ? club.Properties["clubCity"].Value.ToString() : "No club city found"; c.clubRegion = Umbraco.GetPreValueAsString(int.Parse(club.Properties["clubRegion"].Value.ToString())); List <string> templist = new List <String>(); var items = club.Properties["clubSports"].Value.ToString().Split(new Char[] { ',' }); foreach (var item in items) { int temp = int.Parse(item); templist.Add(Umbraco.GetPreValueAsString(temp)); } c.clubSports = templist; try { c.clubLogo = apiUrl + this.getImg(club.Properties["clubLogo"].Value.ToString()); } catch { c.clubLogo = apiUrl + "/media/1001/M1.png"; }; allClubs.Add(c); } return(allClubs); }
public Club GetClub(int cID) { var cs = Services.ContentService; var club = cs.GetById(cID); List <Sponsor> sponsorlist = new List <Sponsor>(); List <Team> teamlist = new List <Team>(); if (club != null) { var c = new Club(); c.clubId = club.Id; c.clubName = (club.Properties["clubName"].Value != null) ? club.Properties["clubName"].Value.ToString() : "No club name found"; c.clubAddress = (club.Properties["clubAddress"].Value != null) ? club.Properties["clubAddress"].Value.ToString() : "No club address found"; c.clubCity = (club.Properties["clubCity"].Value != null) ? club.Properties["clubCity"].Value.ToString() : "No club city found"; var sponsors = cs.GetById(cID).Descendants().Where(t => t.ContentType.Alias.Equals("sponsor")); var teams = cs.GetById(cID).Descendants().Where(t => t.ContentType.Alias.Equals("team")); //var matches = cs.GetById(cID).Descendants().Where(t => t.ContentType.Alias.Equals("Match")); try { c.clubLogo = apiUrl + this.getImg(club.Properties["clubLogo"].Value.ToString()); } catch { c.clubLogo = apiUrl + "/media/1001/M1.png"; }; List <string> templist = new List <String>(); var items = club.Properties["clubSports"].Value.ToString().Split(new Char[] { ',' }); foreach (var item in items) { int temp = int.Parse(item); templist.Add(Umbraco.GetPreValueAsString(temp)); } c.clubSports = templist; foreach (var sponsor in sponsors) { var s = new Sponsor(); s.sponsorId = sponsor.Id; s.sponsorName = (sponsor.Properties["sponsorName"].Value != null) ? sponsor.Properties["sponsorName"].Value.ToString() : "No sponsor name found"; s.sponsorAddress = (sponsor.Properties["sponsorAddress"].Value != null) ? sponsor.Properties["sponsorAddress"].Value.ToString() : "No sponsor address found"; try { s.sponsorLogo = apiUrl + this.getImg(sponsor.Properties["sponsorLogo"].Value.ToString()); } catch { s.sponsorLogo = apiUrl + "/media/1001/M1.png"; }; sponsorlist.Add(s); } c.Sponsors = sponsorlist; foreach (var team in teams) { var t = new Team(); t.teamId = team.Id; t.teamName = (team.Properties["teamName"].Value != null) ? team.Properties["teamName"].Value.ToString() : "Team name"; List <Match> matchlist = new List <Match>(); var matches = cs.GetById(t.teamId).Descendants().Where(te => te.ContentType.Alias.Equals("match")); foreach (var match in matches) { DateTime startDate = DateTime.Parse(match.Properties["matchStartDateTime"].Value.ToString()); string matchDateTime = startDate.ToString("dd. MMMM yyyy", dk); var m = new Match(); m.matchId = match.Id; m.matchHomeTeam = t.teamName; m.matchAddress = (match.Properties["matchAddress"].Value != null) ? match.Properties["matchAddress"].Value.ToString() : "Match Address"; m.matchCity = (match.Properties["matchCity"].Value != null) ? match.Properties["matchCity"].Value.ToString() : "Match City"; m.matchStartDateTime = matchDateTime; m.opponent = (match.Properties["opponent"].Value != null) ? match.Properties["opponent"].Value.ToString() : "Opponent"; m.homeGoal = int.Parse((match.Properties["homeGoal"].Value != null) ? match.Properties["homeGoal"].Value.ToString() : "0"); m.opponentGoal = int.Parse((match.Properties["opponentGoal"].Value != null) ? match.Properties["opponentGoal"].Value.ToString() : "0"); var matchStatus = (match.Properties["status"].Value != null) ? match.Properties["status"].Value.ToString() : "Status"; m.status = Umbraco.GetPreValueAsString(int.Parse(matchStatus)); matchlist.Add(m); } t.teamMatches = matchlist; teamlist.Add(t); } c.Teams = teamlist; //c.Matches = matchlist; return(c); } else { return(new Club()); } }
public Match GetMatchByID(int mID) { var cs = Services.ContentService; List <Sponsor> sponsorlist = new List <Sponsor>(); var match = cs.GetById(mID); int parentID = cs.GetById(mID).ParentId; int parentTeamsID = cs.GetById(parentID).ParentId; var team = cs.GetById(parentTeamsID); int parentClubsID = cs.GetById(parentTeamsID).ParentId; int parentClubID = cs.GetById(parentClubsID).ParentId; var sponsors = cs.GetById(parentClubID).Descendants().Where(sp => sp.ContentType.Alias.Equals("sponsor")); if (match != null) { var teamName = (team.Properties["teamName"].Value != null) ? team.Properties["teamName"].Value.ToString() : "Team name"; DateTime startDate = DateTime.Parse(match.Properties["matchStartDateTime"].Value.ToString()); string matchDateTime = startDate.ToString("dd. MMMM yyyy", dk); var m = new Match(); m.matchId = match.Id; m.matchHomeTeam = teamName; m.matchAddress = (match.Properties["matchAddress"].Value != null) ? match.Properties["matchAddress"].Value.ToString() : "Match Address"; m.matchCity = (match.Properties["matchCity"].Value != null) ? match.Properties["matchCity"].Value.ToString() : "Match City"; m.matchStartDateTime = matchDateTime; m.opponent = (match.Properties["opponent"].Value != null) ? match.Properties["opponent"].Value.ToString() : "Opponent"; m.homeGoal = int.Parse((match.Properties["homeGoal"].Value != null) ? match.Properties["homeGoal"].Value.ToString() : "0"); m.opponentGoal = int.Parse((match.Properties["opponentGoal"].Value != null) ? match.Properties["opponentGoal"].Value.ToString() : "0"); m.manOfTheMatch = (match.Properties["manOfTheMatch"].Value != null) ? match.Properties["manOfTheMatch"].Value.ToString() : "manOfTheMatch"; var temp = (match.Properties["status"]); var matchStatus = (match.Properties["status"].Value != null) ? match.Properties["status"].Value.ToString() : "Status"; m.status = Umbraco.GetPreValueAsString(int.Parse(matchStatus)); foreach (var sponsor in sponsors) { var s = new Sponsor(); s.sponsorId = sponsor.Id; s.sponsorName = (sponsor.Properties["sponsorName"].Value != null) ? sponsor.Properties["sponsorName"].Value.ToString() : "No sponsor name found"; s.sponsorAddress = (sponsor.Properties["sponsorAddress"].Value != null) ? sponsor.Properties["sponsorAddress"].Value.ToString() : "No sponsor address found"; try { s.sponsorLogo = apiUrl + this.getImg(sponsor.Properties["sponsorLogo"].Value.ToString()); } catch { s.sponsorLogo = apiUrl + "/media/1001/M1.png"; }; sponsorlist.Add(s); } m.matchSponsors = sponsorlist; return(m); } else { return(new Match()); } }
public Team GetTeam(int tID) { var cs = Services.ContentService; List <Player> playerlist = new List <Player>(); List <Sponsor> sponsorlist = new List <Sponsor>(); List <Match> matchlist = new List <Match>(); var team = cs.GetById(tID); if (team != null) { var t = new Team(); t.teamId = team.Id; t.teamName = (team.Properties["teamName"].Value != null) ? team.Properties["teamName"].Value.ToString() : "Team name"; t.teamSport = (team.Properties["teamSport"].Value != null) ? team.Properties["teamSport"].Value.ToString() : "Team name"; var matches = cs.GetById(t.teamId).Descendants().Where(te => te.ContentType.Alias.Equals("match")); foreach (var match in matches) { DateTime startDate = DateTime.Parse(match.Properties["matchStartDateTime"].Value.ToString()); string matchDateTime = startDate.ToString("dd. MMMM yyyy", dk); var m = new Match(); m.matchId = match.Id; m.matchHomeTeam = t.teamName; m.matchAddress = (match.Properties["matchAddress"].Value != null) ? match.Properties["matchAddress"].Value.ToString() : "Match Address"; m.matchCity = (match.Properties["matchCity"].Value != null) ? match.Properties["matchCity"].Value.ToString() : "Match City"; m.matchStartDateTime = matchDateTime; m.opponent = (match.Properties["opponent"].Value != null) ? match.Properties["opponent"].Value.ToString() : "Opponent"; m.homeGoal = int.Parse((match.Properties["homeGoal"].Value != null) ? match.Properties["homeGoal"].Value.ToString() : "0"); m.opponentGoal = int.Parse((match.Properties["opponentGoal"].Value != null) ? match.Properties["opponentGoal"].Value.ToString() : "0"); var matchStatus = (match.Properties["status"].Value != null) ? match.Properties["status"].Value.ToString() : "Status"; m.status = Umbraco.GetPreValueAsString(int.Parse(matchStatus)); matchlist.Add(m); } t.teamMatches = matchlist; t.teamPlayers = this.GetPlayersByGuid(team.Properties["teamPlayers"].Value.ToString()); int parentID = cs.GetById(t.teamId).ParentId; int parentClubID = cs.GetById(parentID).ParentId; var sponsors = cs.GetById(parentClubID).Descendants().Where(sp => sp.ContentType.Alias.Equals("sponsor")); foreach (var sponsor in sponsors) { var s = new Sponsor(); s.sponsorId = sponsor.Id; s.sponsorName = (sponsor.Properties["sponsorName"].Value != null) ? sponsor.Properties["sponsorName"].Value.ToString() : "No sponsor name found"; s.sponsorAddress = (sponsor.Properties["sponsorAddress"].Value != null) ? sponsor.Properties["sponsorAddress"].Value.ToString() : "No sponsor address found"; try { s.sponsorLogo = apiUrl + this.getImg(sponsor.Properties["sponsorLogo"].Value.ToString()); } catch { s.sponsorLogo = apiUrl + "/media/1001/M1.png"; }; sponsorlist.Add(s); } t.teamSponsors = sponsorlist; return(t); } else { return(new Team()); } }