public ActionResult TopPeople(string peopleSearch) { #region MemberAction objMember = new MemberAction(); Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); //Search User by name IList<Member> memberSearchList = objMember.GetMembersByName(peopleSearch); if (memberSearchList.Count > 0) { ViewData["MostActive"] = memberSearchList; SessionStore.SetSessionValue(SessionStore.PeopleSearch, memberSearchList); } else { //Most Active if search does not return result IList<Member> memberList = objMember.GetAllMember(); if (memberData != null) { memberList = memberList.Where(x => x.id != memberData.id).OrderByDescending(x => x.Seeds.Count()).ToList(); } else { memberList = memberList.OrderByDescending(x => x.Seeds.Count()).ToList(); } ViewData["MostActive"] = memberList; ViewData["NoResult"] = "Your search did not return any result, showing most active users"; } //Nearby Users CommonMethods objCmnMethods = new CommonMethods(); string strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress; if (strIpAddress == "127.0.0.1") strIpAddress = "61.246.241.162"; string ipLocation = objCmnMethods.IP2AddressAPI(strIpAddress); string zipCodeSearch = string.Empty; string[] currentAddress; if (!string.IsNullOrEmpty(ipLocation)) { //IPaddressAPI currentAddress = ipLocation.Split(','); if (string.IsNullOrEmpty(currentAddress[7].Replace("\"", "").ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[7].Replace("\"", "").ToString(); } else { //MaxMind ipLocation = objCmnMethods.IP2AddressMaxMind(); currentAddress = ipLocation.Split('\''); if (string.IsNullOrEmpty(currentAddress[15].ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[15].ToString(); } IList<Member> lstMember = new List<Member>(); if (memberData != null) lstMember = objMember.GetMembersByZip(zipCodeSearch).Where(x => x.id != memberData.id).ToList(); else lstMember = objMember.GetMembersByZip(zipCodeSearch); ViewData["NearbyUsers"] = lstMember.Distinct().ToList(); return View(); #endregion }
public IList<Seed> getNewestNearby(string radius) { #region CommonMethods objCmnMethods = new CommonMethods(); string strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress; if (strIpAddress == "127.0.0.1") strIpAddress = "61.246.241.162"; string ipLocation = objCmnMethods.IP2AddressAPI(strIpAddress); string citySearch = string.Empty; string stateSearch = string.Empty; string zipCodeSearch = string.Empty; string latSearch = string.Empty; string lngSearch = string.Empty; string[] currentAddress; if (!string.IsNullOrEmpty(ipLocation)) { //IPaddressAPI currentAddress = ipLocation.Split(','); if (string.IsNullOrEmpty(currentAddress[4].Replace("\"", "").ToString())) stateSearch = "AZ"; else stateSearch = currentAddress[4].Replace("\"", "").ToString(); if (string.IsNullOrEmpty(currentAddress[6].ToString())) citySearch = "Phoenix"; else citySearch = currentAddress[6].Replace("\"", "").ToString(); if (string.IsNullOrEmpty(currentAddress[7].Replace("\"", "").ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[7].Replace("\"", "").ToString(); latSearch = currentAddress[8].Replace("\"", "").ToString(); lngSearch = currentAddress[9].Replace("\"", "").ToString(); } else { //MaxMind ipLocation = objCmnMethods.IP2AddressMaxMind(); currentAddress = ipLocation.Split('\''); if (string.IsNullOrEmpty(currentAddress[7].ToString())) stateSearch = "AZ"; else stateSearch = currentAddress[7].ToString(); if (string.IsNullOrEmpty(currentAddress[5].ToString())) citySearch = "Phoenix"; else citySearch = currentAddress[5].ToString(); if (string.IsNullOrEmpty(currentAddress[15].ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[15].ToString(); latSearch = currentAddress[11].ToString(); lngSearch = currentAddress[13].ToString(); } SeedAction objSeed = new SeedAction(); IList<Seed> lstSeed = objSeed.GetAllSeedsByZip(radius, zipCodeSearch); return lstSeed.Where(x => (x.status.Equals(SystemStatements.STATUS_NEW) || x.status.Equals(SystemStatements.STATUS_GROWING))).ToList(); #endregion }
public ActionResult SearchSeeds() { #region CommonMethods objCmnMethods = new CommonMethods(); string strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress; if (strIpAddress == "127.0.0.1") strIpAddress = "61.246.241.162"; string ipLocation = objCmnMethods.IP2AddressAPI(strIpAddress); string citySearch = string.Empty; string stateSearch = string.Empty; string zipCodeSearch = string.Empty; string latSearch = string.Empty; string lngSearch = string.Empty; string[] currentAddress; if (!string.IsNullOrEmpty(ipLocation)) { //IPaddressAPI currentAddress = ipLocation.Split(','); if (string.IsNullOrEmpty(currentAddress[4].Replace("\"", "").ToString())) stateSearch = "AZ"; else stateSearch = currentAddress[4].Replace("\"", "").ToString(); if (string.IsNullOrEmpty(currentAddress[6].ToString())) citySearch = "Phoenix"; else citySearch = currentAddress[6].Replace("\"", "").ToString(); if (string.IsNullOrEmpty(currentAddress[7].Replace("\"", "").ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[7].Replace("\"", "").ToString(); latSearch = currentAddress[8].Replace("\"", "").ToString(); lngSearch = currentAddress[9].Replace("\"", "").ToString(); } else { //MaxMind ipLocation = objCmnMethods.IP2AddressMaxMind(); currentAddress = ipLocation.Split('\''); if (string.IsNullOrEmpty(currentAddress[7].ToString())) stateSearch = "AZ"; else stateSearch = currentAddress[7].ToString(); if (string.IsNullOrEmpty(currentAddress[5].ToString())) citySearch = "Phoenix"; else citySearch = currentAddress[5].ToString(); if (string.IsNullOrEmpty(currentAddress[15].ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[15].ToString(); latSearch = currentAddress[11].ToString(); lngSearch = currentAddress[13].ToString(); } IList<Seed> lstSeed = null; if (SessionStore.GetSessionValue(SessionStore.SearchSeeds) != null) lstSeed = (IList<Seed>)SessionStore.GetSessionValue(SessionStore.SearchSeeds); foreach (Seed sd in lstSeed) { sd.seedDistance = (int)objCmnMethods.distance(Convert.ToDouble(latSearch), Convert.ToDouble(lngSearch), Convert.ToDouble(sd.Location.localLat), Convert.ToDouble(sd.Location.localLong)); } ViewData["SearchSeeds"] = lstSeed; return View(); #endregion }
public ActionResult Streams() { #region CommonMethods objCmnMethods = new CommonMethods(); string strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress; if (strIpAddress == "127.0.0.1") strIpAddress = "61.246.241.162"; string ipLocation = objCmnMethods.IP2AddressAPI(strIpAddress); string zipCodeSearch = string.Empty; string[] currentAddress; if (!string.IsNullOrEmpty(ipLocation)) { //IPaddressAPI currentAddress = ipLocation.Split(','); if (string.IsNullOrEmpty(currentAddress[7].Replace("\"", "").ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[7].Replace("\"", "").ToString(); } else { //MaxMind ipLocation = objCmnMethods.IP2AddressMaxMind(); currentAddress = ipLocation.Split('\''); if (string.IsNullOrEmpty(currentAddress[15].ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[15].ToString(); } StreamAction objStream = new StreamAction(); IList<ssStream> streamData = new List<ssStream>(); streamData = objStream.GetAllStreamByZip(zipCodeSearch); if (streamData.Count() < 1) streamData = objStream.GetLatestStreams(); streamData = streamData.Distinct().ToList(); ViewData["SearchStream"] = streamData; IList<ssStream> latestStreams = new List<ssStream>(); latestStreams = objStream.GetLatestStreams(); ViewData["LatestStreams"] = latestStreams; IList<ssStream> mostPopularStreams = new List<ssStream>(); mostPopularStreams = objStream.GetMostPopularStreams(); ViewData["MostPopular"] = mostPopularStreams; ViewData["SearchTerm"] = "Nearby Feeds"; return View(); #endregion }
public ActionResult AdvanceSearch(string AdvLocation, string currentLocValue, string AnotherLocValue, string LocationAdvSearchRadius, string CoordinatesAdvSearchRadius, string advMedia, string advReplySeeds, string txtAdvSearchIncludeTerms, string txtAdvSearchExcludeTerms) { #region Front Logic Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); SeedAction objSeed = new SeedAction(); string advSearchQuery = "Select Seed.* from Seed where (seed.[status] = 'New' or seed.[status] = 'Growing')"; if (advReplySeeds != "IncludeReplySeeds") advSearchQuery += " and seed.parentSeedID is null"; #region add location in query if (!string.IsNullOrEmpty(AdvLocation)) { if (AdvLocation != "AllLocations") { string radius = string.Empty; string radiusZipList = string.Empty; string ZipCodeAdvSearch = string.Empty; if (AdvLocation == "CurrentLocation") { radius = currentLocValue; CommonMethods objCmnMethods = new CommonMethods(); string strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress; if (strIpAddress == "127.0.0.1") strIpAddress = "61.246.241.162"; string ipLocation = objCmnMethods.IP2AddressAPI(strIpAddress); string[] currentAddress; if (!string.IsNullOrEmpty(ipLocation)) { //IPaddressAPI currentAddress = ipLocation.Split(','); if (string.IsNullOrEmpty(currentAddress[7].Replace("\"", "").ToString())) ZipCodeAdvSearch = "85027"; else ZipCodeAdvSearch = currentAddress[7].Replace("\"", "").ToString(); } else { //MaxMind ipLocation = objCmnMethods.IP2AddressMaxMind(); currentAddress = ipLocation.Split('\''); if (string.IsNullOrEmpty(currentAddress[15].ToString())) ZipCodeAdvSearch = "85027"; else ZipCodeAdvSearch = currentAddress[15].ToString(); } } if (AdvLocation == "NewLocation") { radius = AnotherLocValue; //Format address string[] splitAddressSearch = LocationAdvSearchRadius.Split(','); if (splitAddressSearch.Length > 4) { string[] splitZipRegion = splitAddressSearch[3].ToString().Trim().Split(' '); ZipCodeAdvSearch = splitZipRegion[1].ToString().Trim(); } else { string[] splitZipRegion = splitAddressSearch[2].ToString().Trim().Split(' '); ZipCodeAdvSearch = splitZipRegion[1].ToString().Trim(); } //End formatting address } //Get zip codes according to radius CommonMethods objCommon = new CommonMethods(); radiusZipList = objCommon.GetZipByRadiusNew(radius, ZipCodeAdvSearch); //End get zip codes according to radius if (string.IsNullOrEmpty(radiusZipList)) radiusZipList = ZipCodeAdvSearch; advSearchQuery += " and locationId in (Select id from Location where zipcode in (" + radiusZipList + "))"; } } #endregion #region include terms in query if (!string.IsNullOrEmpty(txtAdvSearchIncludeTerms)) { string inCondition = string.Empty; string[] includeTerms = txtAdvSearchIncludeTerms.Split(','); for (int i = 0; i < includeTerms.Length; i++) { if (i == 0) inCondition = "'" + includeTerms[i].ToString() + "'"; else inCondition += ",'" + includeTerms[i].ToString() + "'"; } advSearchQuery += " and Seed.id in (select sc.seedId from Category c ,Seed_has_Category sc where c.id=sc.categoryId and c.name in (" + inCondition + ") union select Seed.id from Seed,Member where Member.id = Seed.ownerId and Member.firstName in (" + inCondition + "))"; } #endregion #region exclude terms in query if (!string.IsNullOrEmpty(txtAdvSearchExcludeTerms)) { string exCondition = string.Empty; string[] excludeTerms = txtAdvSearchExcludeTerms.Split(','); for (int i = 0; i < excludeTerms.Length; i++) { if (i == 0) exCondition = "'" + excludeTerms[i].ToString() + "'"; else exCondition += ",'" + excludeTerms[i].ToString() + "'"; } advSearchQuery += " and Seed.id not in (select sc.seedId from Category c ,Seed_has_Category sc where c.id=sc.categoryId and c.name in (" + exCondition + ") union select Seed.id from Seed,Member where Member.id = Seed.ownerId and Member.firstName in (" + exCondition + "))"; } #endregion #region add media in query if (!string.IsNullOrEmpty(advMedia)) { switch (advMedia) { case "All": advSearchQuery += " and Seed.id in (Select m.seedId from Media m)"; break; case "NoMedia": advSearchQuery += " and Seed.id not in (Select m.seedId from Media m)"; break; case "PhotosOnly": advSearchQuery += " and Seed.id in (Select m.seedId from Media m where m.[type]='" + SystemStatements.MEDIA_IMAGE + "')"; break; case "VideosOnly": advSearchQuery += " and Seed.id in (Select m.seedId from Media m where m.[type]='" + SystemStatements.MEDIA_VIDEO + "')"; break; default: break; } } #endregion IList<Seed> lstSeed = null; lstSeed = objSeed.GetSeedListByCriteria(advSearchQuery); lstSeed = lstSeed.Distinct().ToList(); SessionStore.SetSessionValue(SessionStore.SearchSeeds, lstSeed); TempData["DiscoverSeed"] = "AdvanceSearch"; #endregion return RedirectToAction("SearchSeeds", "Home"); }