using System.Collections.Generic;
using System.Text.RegularExpressions;
public static void Main()
int UnitForSaleCount = 2;
int UnitForRentCount = 0;
string NeighborHood = "Liberty Village";
string NeighborHoodParent = "Downtown";
string UnitNumber = "PH05";
string UnitType = "Penthouse";
float UnitPriceMinForSale = 314000.00f;
float UnitPriceMaxForSale = 3900000.00f;
float UnitMonthlyPriceMinForRent = 3400000.00f;
float UnitMonthlyPriceMaxForRent = 3900000.00f;
string UnitPrice = "$ 1 550 000";
string UnitPhotoType = "Bedroom";
string StreetAddress = "5 Hanna";
string StreetType = "Ave";
string BuildingName = "Liberty Market Lofts";
Console.WriteLine("Building");
Console.WriteLine("--------");
Console.WriteLine("Title: " + BuildingTitle(StreetAddress, StreetType, City, BuildingName));
Console.WriteLine("Keyword: " + BuildingKeyword(StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, UnitForSaleCount, UnitForRentCount));
Console.WriteLine("Description: " + BuildingDescription(StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, UnitForSaleCount, UnitForRentCount));
Console.WriteLine("MetaDescription: " + BuildingDescription(StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, UnitForSaleCount, UnitForRentCount));
Console.WriteLine("Slug: " + BuildingSlug(StreetAddress, StreetType, BuildingName).ToUri());
Console.WriteLine("URI: " + BuildingURI(NeighborHoodParent, NeighborHood, StreetAddress, StreetType, City, BuildingName));
Console.WriteLine("\r\nUnit");
Console.WriteLine("----");
Console.WriteLine("Title: " + UnitTitle(UnitNumber, StreetAddress, StreetType, City, BuildingName, isForSale, isForRent, UnitType, UnitPrice));
Console.WriteLine("Keyword: " + UnitKeyword(UnitNumber, StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, isForSale, isForRent, UnitType));
Console.WriteLine("Description: " + UnitDescription(UnitNumber, StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, isForSale, isForRent, UnitType));
Console.WriteLine("MetaDescription: " + UnitDescription(UnitNumber, StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, isForSale, isForRent, UnitType));
Console.WriteLine("Slug: " + UnitSlug(UnitNumber, StreetAddress, StreetType, City, BuildingName, isForSale, isForRent, UnitType, UnitPrice));
Console.WriteLine("URI: " + UnitURI(NeighborHoodParent, NeighborHood, UnitNumber, StreetAddress, StreetType, City, BuildingName, isForSale, isForRent, UnitType, UnitPrice));
Console.WriteLine("\r\nUnitPhoto");
Console.WriteLine("---------");
Console.WriteLine("Title: " + UnitPhotoTitle(UnitNumber, StreetAddress, StreetType, City, BuildingName, isForSale, isForRent, UnitType, UnitPrice, UnitPhotoType));
Console.WriteLine("Keyword: " + UnitPhotoKeyword(UnitNumber, StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, isForSale, isForRent, UnitType, UnitPhotoType));
Console.WriteLine("Description: " + UnitPhotoDescription(UnitNumber, StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, isForSale, isForRent, UnitType));
Console.WriteLine("MetaDescription: " + UnitPhotoDescription(UnitNumber, StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, isForSale, isForRent, UnitType));
Console.WriteLine("Slug: " + UnitPhotoSlug(UnitNumber, StreetAddress, StreetType, City, BuildingName, isForSale, isForRent, UnitType, UnitPrice, UnitPhotoType));
Console.WriteLine("URI: " + UnitPhotoURI(NeighborHoodParent, NeighborHood, UnitNumber, StreetAddress, StreetType, City, BuildingName, isForSale, isForRent, UnitType, UnitPrice, UnitPhotoType));
Console.WriteLine("Alternative Text: " + UnitPhotoDescription(UnitNumber, StreetAddress, StreetType, City, BuildingName, NeighborHoodParent, NeighborHood, isForSale, isForRent, UnitType));
Console.WriteLine("Caption: " + UnitPhotoTitle(UnitNumber, StreetAddress, StreetType, City, BuildingName, isForSale, isForRent, UnitType, UnitPrice, UnitPhotoType));
static string BuildingTitle(string StreetAddress, string StreetType, string City, string BuildingName) {
string BuildingAddress = StreetAddress + " " + StreetType + ", " + City;
string seperator = (BuildingName.Trim() == "") ? "" : " - ";
return BuildingName + seperator + BuildingAddress;
static string BuildingKeyword(string StreetAddress, string StreetType, string City, string BuildingName, string NeighborHoodParent, string NeighborHood, int UnitForSaleCount, int UnitForRentCount)
List<string> keywordList = new List<string>();
BuildingName.AddToList(keywordList);
StreetAddress.AddToList(keywordList);
StreetType.AddToList(keywordList);
City.AddToList(keywordList);
NeighborHoodParent.AddToList(keywordList);
NeighborHood.AddToList(keywordList);
if (UnitForSaleCount > 0) keywordList.Add("Sale");
if (UnitForRentCount > 0) keywordList.Add("Rent");
ret = string.Join(" ", keywordList.ToArray());
static string BuildingDescription(string StreetAddress, string StreetType, string City, string BuildingName, string NeighborHoodParent, string NeighborHood, int UnitForSaleCount, int UnitForRentCount)
string ret = "{BuildingName} is located at {BuildingAddress} in the {NeighborHoodParent},{NeighborHood}. It has {containsForSaleUnit} for sale and {containsForRentUnit} for rent";
static string BuildingSlug(string StreetAddress, string StreetType, string BuildingName)
return (BuildingName + " " + StreetAddress + " " + StreetType).ToUri();
static string BuildingURI(string NeighborHoodParent, string NeighborHood, string StreetAddress, string StreetType, string City, string BuildingName)
string Slug = (BuildingName + " " + StreetAddress + " " + StreetType).ToUri();
return City.ToUri() + "/" + NeighborHoodParent.ToUri() + "/" + NeighborHood.ToUri() + "/" + Slug;
static string UnitTitle(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, bool isForSale, bool isForRent, string UnitType, string UnitPrice)
string BuildingAddress = UnitNumber + "-" + StreetAddress + " " + StreetType + ", " + City;
if (isForSale) SaleOrRent = " for sale - ";
if (isForRent) SaleOrRent = " for rent - ";
return BuildingAddress + " - " + UnitType + SaleOrRent + UnitPrice;
static string UnitKeyword(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, string NeighborHoodParent, string NeighborHood, bool isForSale, bool isForRent,string UnitType)
List<string> keywordList = new List<string>();
UnitType.AddToList(keywordList);
UnitNumber.AddToList(keywordList);
BuildingName.AddToList(keywordList);
StreetAddress.AddToList(keywordList);
StreetType.AddToList(keywordList);
City.AddToList(keywordList);
NeighborHoodParent.AddToList(keywordList);
NeighborHood.AddToList(keywordList);
if (isForSale) keywordList.Add("Sale");
if (isForRent) keywordList.Add("Rent");
ret = string.Join(" ", keywordList.ToArray());
static string UnitDescription(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, string NeighborHoodParent, string NeighborHood, bool isForSale, bool isForRent, string UnitType)
static string UnitSlug(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, bool isForSale, bool isForRent, string UnitType, string UnitPrice)
if (isForSale) SaleOrRent = "for sale";
if (isForRent) SaleOrRent = "for rent";
return (UnitType + " " + UnitNumber + " " + SaleOrRent).ToUri();
static string UnitURI(string NeighborHoodParent, string NeighborHood, string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, bool isForSale, bool isForRent, string UnitType, string UnitPrice)
if (isForSale) SaleOrRent = "for sale";
if (isForRent) SaleOrRent = "for rent";
string BuildingSlug = (BuildingName + " " + StreetAddress + " " + StreetType).ToUri();
string Slug = (UnitType + " " + UnitNumber + " " + SaleOrRent).ToUri();
return City.ToUri() + "/" + NeighborHoodParent.ToUri() + "/" + NeighborHood.ToUri() + "/" + BuildingSlug + "/" + Slug;
static string UnitPhotoTitle(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, bool isForSale, bool isForRent, string UnitType, string UnitPrice, string UnitPhotoType)
if (isForSale) SaleOrRent = "for sale";
if (isForRent) SaleOrRent = "for rent";
return UnitPhotoType + " at " + StreetAddress + " " + StreetType + ", " + City + ", " + UnitType + " " + UnitNumber + " " + SaleOrRent;
static string UnitPhotoKeyword(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, string NeighborHoodParent, string NeighborHood, bool isForSale, bool isForRent, string UnitType, string UnitPhotoType)
List<string> keywordList = new List<string>();
UnitType.AddToList(keywordList);
UnitNumber.AddToList(keywordList);
UnitPhotoType.AddToList(keywordList);
BuildingName.AddToList(keywordList);
StreetAddress.AddToList(keywordList);
StreetType.AddToList(keywordList);
City.AddToList(keywordList);
NeighborHoodParent.AddToList(keywordList);
NeighborHood.AddToList(keywordList);
if (isForSale) keywordList.Add("Sale");
if (isForRent) keywordList.Add("Rent");
ret = string.Join(" ", keywordList.ToArray());
static string UnitPhotoDescription(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, string NeighborHoodParent, string NeighborHood, bool isForSale, bool isForRent, string UnitType)
static string UnitPhotoSlug(string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, bool isForSale, bool isForRent, string UnitType, string UnitPrice, string UnitPhotoType)
return (UnitPhotoType + " " + UnitType + " " + UnitNumber).ToUri();
static string UnitPhotoURI(string NeighborHoodParent, string NeighborHood, string UnitNumber, string StreetAddress, string StreetType, string City, string BuildingName, bool isForSale, bool isForRent, string UnitType, string UnitPrice, string UnitPhotoType)
if (isForSale) SaleOrRent = "for sale";
if (isForRent) SaleOrRent = "for rent";
string BuildingSlug = (BuildingName + " " + StreetAddress + " " + StreetType).ToUri();
string Slug = (UnitPhotoType + " " + UnitType + " " + UnitNumber).ToUri();
return City.ToUri() + "/" + NeighborHoodParent.ToUri() + "/" + NeighborHood.ToUri() + "/" + BuildingSlug + "/" + Slug;
static class ExtentionUtil
public static void AddToList(this string inputStr, List<string> inputList)
if (inputStr.Trim() != "") inputList.Add(inputStr);
public static string addCondoKeyword(this string inputStr)
return inputStr + ((inputStr.Trim() != "" && inputStr.ToLower().Contains("condo")) ? "" : " Condo");
public static string ToUri(this string inputStr)
string str = inputStr.RemoveAccent().ToLower();
str = Regex.Replace(str, @"[^a-z0-9\s-]", "");
str = Regex.Replace(str, @"\s+", " ").Trim();
str = str.Substring(0, str.Length <= 255 ? str.Length : 255).Trim();
str = Regex.Replace(str, @"\s", "-");
public static string RemoveAccent(this string inputStr)
byte[] bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(inputStr);
return System.Text.Encoding.ASCII.GetString(bytes);