public IEnumerable GetParents(string childTitle, int? childId, int? languageId) { IEnumerable parents = null; using (UltimateDataContext dc = new UltimateDataContext()) { parents = (from p in dc.GetParents(null, childId, languageId) orderby p.ParentTitle ascending select new { Id = p.ParentId, Title = p.ParentTitle, Type = p.ObjectTypeCode }).ToList(); } return parents; }
protected void Page_Load(object sender, EventArgs e) { dc = new UltimateDataContext(); FetchAccommodation(); ContactAgency1.AgencyEmail = accommodation.Agency.ContactEmail; ContactAgency1.AgencyName = accommodation.Agency.Name; if (!IsPostBack) { SetJavascriptVariables(); int languageId = Common.GetLanguageId(); var agency = accommodation.Agency; this.Title = String.Format(Resources.placeberry.AgencyListing_Title, agency.Name + " - " + accommodation.Name); string agencyUrl = string.Empty; var agencyUrlTag = agency.AgencyUrlTags.SingleOrDefault(); if (agencyUrlTag == null) { agencyUrl = "/Agency.aspx?id=" + agency.Id; } else { agencyUrl = Common.GenerateAgencyUrl(agencyUrlTag.UrlTag); } aAgencyLogo.HRef = agencyUrl; aAgencyName.HRef = agencyUrl; aAgencyName.InnerText = agency.Name; ltlAgencyAdress.Text = String.Format("{0}, {1}, {2}", agency.Address, agency.City, agency.Country); ltlAgencyEmail.Text = agency.ContactEmail; ltlAgencyPhones.Text = agency.ContactPhone; if (agency.Image != null) { imgAgencyLogo.Src = "/thumb.aspx?src=" + agency.Image.Src + "&mw=185&mh=160&crop=1"; imgAgencyLogo.Alt = agency.Image.Alt; } else { imgAgencyLogo.Src = "/resources/noimg.jpg"; imgAgencyLogo.Alt = ""; } aAgencyWebsite.HRef = agency.UrlWebsite ?? "#"; aAgencyWebsite.InnerText = agency.UrlWebsite ?? string.Empty; ltlListingTitle.Text = accommodation.Name; ltlListingType.Text = dc.GetTraslation(accommodation.TypeId, languageId); ltlListingCapacity.Text = Common.FormatCapacity(accommodation.CapacityMin, accommodation.CapacityMax); var descriptions = from p in accommodation.AccommodationDescriptions where p.LanguageId == languageId || p.LanguageId == accommodation.Agency.LangaugeId select p; string translation = descriptions.Where(i => i.LanguageId == languageId).Select(i => i.Description).SingleOrDefault() ?? descriptions.Where(i => i.LanguageId == agency.LangaugeId).Select(i => i.Description).SingleOrDefault(); ltlListingDescription.Text = translation ?? string.Empty; string location = dc.GetTraslation(accommodation.AccommodationCity.UltimateTableId, languageId); var parents = (from p in dc.GetParents(null, accommodation.AccommodationCity.UltimateTableId, languageId) orderby p.Lvl select p.ParentTitle).ToArray(); if (parents.Any()) { location += ", " + string.Join(", ", parents); } ltlListingLocation.Text = location; RefeshGallery(); RefreshPrices(); } }
protected void GetChildren() { using (UltimateDataContext dc = new UltimateDataContext()) { var children = from p in dc.UltimateTableRelations where p.Active == true && p.Child.Active == true && p.Parent.Title.ToLower() == parentTerm && p.Child.UltimateTableObjectType.GroupCode == "GEO" select p.Child; var parents = from p in dc.UltimateTableRelations where p.Active == true && p.Parent.Active == true && p.Child.Title.ToLower() == parentTerm select p.Parent; var brothers = from p in dc.UltimateTableRelations where p.Active == true && p.Child.Active == true && parents.Contains(p.Parent) && p.Child.Title.ToLower() != parentTerm && p.Child.UltimateTableObjectType.GroupCode == "GEO" select p.Child; //Ako parent nema djece onda ispisuje braću var query = children.Any() ? children : brothers; //LEFT OUTER JOIN pa ako nema prijevoda onda prikazujemo Title iz UltimateTable var translation = from p in query join q in dc.UltimateTableTranslations on p equals q.UltimateTable into trans from r in trans.Where(i => i.Language.Abbrevation == language && i.Active == true).DefaultIfEmpty() select new { UltimateId = p.Id, Title = r != null ? r.Title : p.Title }; if (translation.Any()) { var trans = translation.Take(1).SingleOrDefault(); var parentnodes = (from p in dc.GetParents(null, trans.UltimateId, Common.GetLanguageId()) select p.ParentTitle).ToArray(); //string parentlink = parentnodes.Any() ? string.Join(" ", parentnodes) + " " : string.Empty; aParent.HRef = string.Format("{0}?{1}{2}={3}", landingPage, queryString, queryStringVar, HttpUtility.UrlEncode(parentnodes.Last())); aParent.InnerText = parentnodes.Last(); var data = from p in translation select new { Href = String.Format("{0}?{1}{2}={3}", landingPage, queryString, queryStringVar, HttpUtility.UrlEncode(p.Title)), Title = p.Title }; repDirectory.DataSource = data; repDirectory.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { int languageId = Common.GetLanguageId(); string termTag = Request.QueryString["tag"] ?? string.Empty; termTag = termTag.Split('/').LastOrDefault(); Repeater topAdverts = TopAdverts.Adverts; if (!string.IsNullOrEmpty(termTag)) { using (UltimateDataContext dc = new UltimateDataContext()) { var query = (from p in dc.UltimateTableUrlTags where p.UrlTag == termTag && p.LanguageId == languageId select new { Id = p.UltimateTable.Id, Title = p.UltimateTable.Title, UrlTag = p.UrlTag }).Distinct(); if (query.Any()) { var term = query.First(); string termTitle = (from p in dc.UltimateTableTranslations where p.UltimateTableId == term.Id && p.Active == true && p.LanguageId == languageId select p.Title).SingleOrDefault() ?? term.Title; ltlCurrentTerm.Text = termTitle; this.Title = String.Format(Resources.placeberry.Directory_TitleFormat, termTitle); string termDesc = (from p in dc.UltimateTableInfos where p.UltimateTableId == term.Id && p.LanguageId == languageId select p.WikiDescription).SingleOrDefault() ?? string.Empty; if (!string.IsNullOrEmpty(termDesc)) { termDesc = termDesc.Replace("\n", "<br />"); ltlDescription.Text = termDesc; pnlDescription.Visible = true; } else { pnlDescription.Visible = false; } //BREADCRUMBS //dodajemo root breadcrumbs.Add(new UltimateTerm() { Id = 0, Title = "dir", UrlLink = Resources.placeberry.URL_Directory, UrlTag = Resources.placeberry.URL_Directory }); //dodajemo ostale elemente breadcrumbs.AddRange(from p in dc.GetParents(null, term.Id, languageId) where p.ObjectTypeGroupCode != null && p.ObjectTypeGroupCode == "GEO" select new UltimateTerm() { Id = p.ParentId, Title = p.ParentTitle, UrlTag = p.UrlTag, UrlLink = string.Empty }); //gradimo linkove for (int i = 1; i < breadcrumbs.Count; i++) { breadcrumbs[i].UrlLink = breadcrumbs[i - 1].UrlLink + "/" + breadcrumbs[i].UrlTag; } //dodajemo trenutni pojam zato što GetParents vrati samo roditelje, a ne i trenutni var currTerm = new UltimateTerm() { Id = term.Id, Title = termTitle, UrlTag = term.UrlTag }; var previousTerm = breadcrumbs.Last(); breadcrumbs.Add(currTerm); currTerm.UrlLink = previousTerm.UrlLink + "/" + currTerm.UrlTag; repBreadcrumbs.DataSource = breadcrumbs; repBreadcrumbs.DataBind(); //CHILDREN var children = from p in dc.UltimateTableRelations where p.ParentId == term.Id && p.Child.UltimateTableObjectType.GroupCode == "GEO" select p.Child; var childrenTranslated = from p in children join q in dc.UltimateTableTranslations on p equals q.UltimateTable into trans join t in dc.UltimateTableUrlTags on p equals t.UltimateTable into tags from r in trans.Where(i => i.LanguageId == languageId && i.Active == true).DefaultIfEmpty() from s in tags.Where(i => i.LanguageId == languageId).DefaultIfEmpty() select new { Id = p.Id, Title = r != null ? r.Title : p.Title, UrlLink = String.Format("{0}/{1}", currTerm.UrlLink, s.UrlTag) }; if (childrenTranslated.Any()) { repChildren.DataSource = childrenTranslated; repChildren.DataBind(); } else { repChildren.Visible = false; } string queryMessage = string.Empty; topAdverts.DataSource = Placeberry.DAL.GetResults.Execute(termTitle, languageId, 5, 0, 5, 0, out queryMessage); topAdverts.DataBind(); aCurrentTerm.HRef = String.Format("/{0}?q={1}", Resources.placeberry.General_VacationUrl, termTitle); aCurrentTerm.InnerText = String.Format(Resources.placeberry.Directory_SearchCurrentTerm, termTitle); aCurrentTerm.Visible = true; string keywords = string.Join(", ", breadcrumbs.Skip(1).Select(i => i.Title).ToArray()); HtmlMeta metaKeywords = new HtmlMeta() { Name = "keywords", Content = string.Empty }; HtmlMeta metaDescription = new HtmlMeta() { Name = "description", Content = string.Empty }; metaDescription.Content = String.Format(Resources.placeberry.Directory_MetaDescription, termTitle); metaKeywords.Content = String.Format(Resources.placeberry.Directory_MetaKeywords, keywords); Header.Controls.Add(metaDescription); Header.Controls.Add(metaKeywords); } else { //ERROR ne postoji taj pojam u direktoriju } } } else { using (UltimateDataContext dc = new UltimateDataContext()) { var countries = from p in dc.UltimateTables where p.Active == true && p.UltimateTableObjectType.Code == "COUNTRY" select p; var countriesTranslated = from p in countries join q in dc.UltimateTableTranslations on p equals q.UltimateTable into trans join t in dc.UltimateTableUrlTags on p equals t.UltimateTable into tags from r in trans.Where(i => i.LanguageId == languageId && i.Active == true).DefaultIfEmpty() from s in tags.Where(i => i.LanguageId == languageId).DefaultIfEmpty() select new { Id = p.Id, Title = r != null ? r.Title : p.Title, UrlLink = String.Format("{0}/{1}", Resources.placeberry.URL_Directory, s.UrlTag) }; if (countriesTranslated.Any()) { repChildren.DataSource = countriesTranslated; repChildren.DataBind(); } ltlTopAdsText.Visible = false; topAdverts.Visible = false; HtmlMeta metaKeywords = new HtmlMeta() { Name = "keywords", Content = string.Empty }; HtmlMeta metaDescription = new HtmlMeta() { Name = "description", Content = string.Empty }; metaDescription.Content = String.Format(Resources.placeberry.Directory_MetaDescription, "smještaj"); metaKeywords.Content = String.Format(Resources.placeberry.Directory_MetaKeywords, "smještaj"); Header.Controls.Add(metaDescription); Header.Controls.Add(metaKeywords); } } }
protected void GetCountrys() { using (UltimateDataContext dc = new UltimateDataContext()) { var children = from p in dc.UltimateTables where p.Active == true && (ObjectType)p.ObjectTypeId == ObjectType.COUNTRY select p; //LEFT OUTER JOIN pa ako nema prijevoda onda prikazujemo Title iz UltimateTable var translation = from p in children join q in dc.UltimateTableTranslations on p equals q.UltimateTable into trans from r in trans.Where(i => i.Language.Abbrevation == language).DefaultIfEmpty() select new { UltimateId = p.Id, Title = r != null ? r.Title : p.Title }; if (translation.Any()) { var trans = translation.Take(1).SingleOrDefault(); var parentnodes = (from p in dc.GetParents(null, trans.UltimateId, Common.GetLanguageId()) select p.ParentTitle).ToArray(); //string parentlink = parentnodes.Any() ? string.Join(" ", parentnodes) + " " : string.Empty; var data = from p in translation select new { Href = String.Format("{0}?{1}{2}={3}", landingPage, queryString, queryStringVar, HttpUtility.UrlEncode(p.Title)), Title = p.Title }; repDirectory.DataSource = data; repDirectory.DataBind(); } } }