コード例 #1
0
        public IList<Seed> HomeSearchSeeds(string Criteria, string sortBy, string radius, string counter)
        {
            #region
            SeedAction objSeed = new SeedAction();
            IList<Seed> seedData = new List<Seed>();
            IList<Seed> tmpSeedList = null;
            CategoryAction objCategory = new CategoryAction();

            string searchOthers = "";
            string searchZip = "";
            int seedCounter = Convert.ToInt32(counter) + 1;

            string[] criteriaArr = Criteria.Trim().Split(' ');

            foreach (string str in criteriaArr)
            {
                if (this.checkCriteria(str))
                {
                    searchZip = str;
                }
                else
                {
                    searchOthers = searchOthers + " " + str;
                }
            }

            searchOthers = searchOthers.Trim();

            if (searchZip.Length > 0)
            {
                tmpSeedList = objSeed.GetAllSeedsByZip(radius, searchZip);

                foreach (Seed sData in tmpSeedList)
                {
                    seedData.Add(sData);
                }
            }

            if (searchOthers.Length > 0 && seedData.Distinct().ToList().Count < seedCounter)
            {
                IList<Category> catList = objCategory.GetAllCategoriesByName(searchOthers);

                foreach (Category cat in catList)
                {
                    tmpSeedList = objSeed.GetAllSeedsByCategory(cat.id.ToString());
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetAllSeedsByTitle(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetAllSeedsByDescription(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetSeedByCrossStreet(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }
                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetSeedByCity(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

            }
            seedData = seedData.Distinct().Take(seedCounter).ToList();
            return seedData;
            #endregion
        }
コード例 #2
0
        /// <summary>
        /// Search Seeds
        /// </summary>
        /// <param name="Criteria"></param>
        /// <param name="sortBy"></param>
        /// <param name="radius"></param>
        /// <param name="counter"></param>
        /// <returns></returns>
        public IList<SeedDetail> SearchSeeds(string Criteria, string sortBy, string radius, string counter)
        {
            SeedAction objSeed = new SeedAction();
            IList<Seed> seedData = new List<Seed>();
            IList<Seed> tmpSeedList = null;
            CategoryAction objCategory = new CategoryAction();

            string searchOthers = "";
            string searchZip = "";
            int seedCounter = Convert.ToInt32(counter) + 1;

            string[] criteriaArr = Criteria.Trim().Split(' ');

            foreach (string str in criteriaArr)
            {
                //Checking that searchstring contains zipcode
                if (this.checkCriteria(str))
                {
                    searchZip = str;
                }
                else
                {
                    searchOthers = searchOthers + " " + str;
                }
            }

            searchOthers = searchOthers.Trim();

            if (searchZip.Length > 0)
            {
               // radius = "50";
                tmpSeedList = objSeed.GetAllSeedsByZip(radius, searchZip);

                foreach (Seed sData in tmpSeedList)
                {
                    if (sData.status.Equals(SystemStatements.STATUS_NEW) || sData.status.Equals(SystemStatements.STATUS_GROWING))
                    {
                        seedData.Add(sData);
                    }
                    //seedData.Add(sData);
                }
            }

            if (searchOthers.Length > 0 && seedData.Distinct().ToList().Count < seedCounter)
            {
                //Searching in Category
                IList<Category> catList = objCategory.GetAllCategoriesByName(searchOthers);

                foreach (Category cat in catList)
                {
                    tmpSeedList = objSeed.GetAllSeedsByCategory(cat.id.ToString());
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetAllSeedsByTitle(searchOthers);
                    foreach (Seed sData in tmpSeedList)

                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    //Searching in Description
                    tmpSeedList = objSeed.GetAllSeedsByDescription(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    //Searching in FirstName
                    tmpSeedList = objSeed.GetAllSeedsByUserName(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    //Searching in CrossStreet
                    tmpSeedList = objSeed.GetSeedByCrossStreet(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }
                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    //Searching in City
                    tmpSeedList = objSeed.GetSeedByCity(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

            }

              //  string tmp = "";

            seedData = seedData.Distinct().Take(seedCounter).ToList();

            if (!string.IsNullOrEmpty(sortBy))
            {
                switch (sortBy)
                {
                    case "1":
                        seedData = seedData.OrderBy(x => x.Categories.FirstOrDefault() != null ? x.Categories.FirstOrDefault().name : "").ToList();
                        break;
                    case "2":
                        seedData = seedData.OrderBy(x => x.Location.zipcode).ToList();
                        break;
                    case "3":
                        seedData = seedData.OrderBy(x => x.title).ToList();
                        break;
                    default:
                        seedData = seedData.OrderBy(x => x.title).ToList();
                        break;
                }
            }

            string tmpCName = "";

            IList<SeedDetail> lstSeedList = new List<SeedDetail>();

            foreach (Seed s in seedData)
            {

                SeedDetail objSeedDetail = new SeedDetail();

                string imgPath = "No Image";

                int likesCount = s.Ratings.Where(x => x.likes.Equals("Like")).ToList().Count;
                int replyCount =Convert.ToInt16(objSeed.GetReplySeedCount(s.id.ToString()));// s.Commitments.ToList().Count;
                int commentsCount = s.Comments.ToList().Count;

                if (s.Media != null && s.Media.Count > 0)
                {
                    imgPath = s.Media.FirstOrDefault().path;

                    imgPath = imgPath.Substring(imgPath.LastIndexOf('/'));

                    if (imgPath.Length > 1)
                        imgPath = System.Configuration.ConfigurationManager.AppSettings["RootURL"].ToString() + "/UploadedMedia" + imgPath;
                    else
                        imgPath = "No Image";
                }

                objSeedDetail.SeedID = s.id.ToString();
                objSeedDetail.Title = s.title;

                if (s.Location.City != null)
                {
                   // tmp += "||" + s.Location.City.name;
                    objSeedDetail.City = s.Location.City.name;
                }

                if (s.Location.City.Region != null)
                {
                    objSeedDetail.State = s.Location.City.Region.code;
                    //tmp += "||" + s.Location.City.Region.code;
                }

                if (s.Location != null)
                {
                    objSeedDetail.Zip = s.Location.zipcode;
                  //  tmp += "||" + s.Location.zipcode;
                }
                objSeedDetail.Path = imgPath;
               // tmp += "||" + imgPath;

                if (s.Categories != null && s.Categories.Count > 0)
                {
                    tmpCName = s.Categories.FirstOrDefault().name;
                }

                if (s.Location != null)
                {

                    objSeedDetail.Latitude = s.Location.localLat.ToString();
                    objSeedDetail.Longitude = s.Location.localLong.ToString();
                }
                objSeedDetail.TempCategory = tmpCName;
               // tmp += "||" + tmpCName;

                objSeedDetail.MemberName = s.Member.firstName + " " + s.Member.lastName;
                objSeedDetail.Address = s.Location.crossStreet;
                objSeedDetail.CreateDate = Convert.ToDateTime(s.createDate).ToString();
                objSeedDetail.Description = s.description;
                objSeedDetail.Likes = likesCount + " Likes";
                objSeedDetail.Comments = commentsCount + " Comments";
                objSeedDetail.ReplySeeds = replyCount + " Reply Seeds";
                objSeedDetail.PopularCount = (likesCount + commentsCount + replyCount).ToString();
                //tmp += "||" + s.Member.firstName + " " + s.Member.lastName + "||" + s.Location.crossStreet + "||" + Convert.ToDateTime(s.createDate).ToString("dd MMMM yyyy") + "||" + s.description + "||" + likesCount + " Likes" + "||" + commitmentCount + " Commitments" + "||" + commentsCount + " Comments";

                string tmpCategory = "";
                foreach (Category c in s.Categories)
                {
                    if (tmpCategory.Length > 0)
                        tmpCategory = tmpCategory + "," + c.name;
                    else
                        tmpCategory = c.name;
                }
                objSeedDetail.Categories = tmpCategory;
             //   tmp = tmp + "||" + tmpCategory;

                lstSeedList.Add(objSeedDetail);
            }//For each seed

            return lstSeedList;
        }
コード例 #3
0
        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
        }
コード例 #4
0
        public string SearchSeeds(string Criteria, string sortBy,string radius,string counter)
        {
            #region
            SeedAction objSeed = new SeedAction();
            IList<Seed> seedData = new List<Seed>();
            IList<Seed> tmpSeedList = null;
            CategoryAction objCategory = new CategoryAction();

            string searchOthers = "";
            string searchZip = "";
            int seedCounter = Convert.ToInt32(counter) + 1;

            string[] criteriaArr = Criteria.Trim().Split(' ');

            foreach(string str in criteriaArr)
            {
                if (this.checkCriteria(str))
                {
                    searchZip = str;
                }
                else
                {
                    searchOthers = searchOthers + " " + str;
                }
            }

            searchOthers = searchOthers.Trim();

            if (searchZip.Length > 0)
            {
                tmpSeedList = objSeed.GetAllSeedsByZip(radius, searchZip);

                foreach (Seed sData in tmpSeedList)
                {
                    seedData.Add(sData);
                }
            }

            if (searchOthers.Length > 0 && seedData.Distinct().ToList().Count < seedCounter)
            {
                IList<Category> catList = objCategory.GetAllCategoriesByName(searchOthers);

                foreach (Category cat in catList)
                {
                    tmpSeedList = objSeed.GetAllSeedsByCategory(cat.id.ToString());
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetAllSeedsByTitle(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetAllSeedsByDescription(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetSeedByCrossStreet(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }
                if (seedData.Distinct().ToList().Count < seedCounter)
                {
                    tmpSeedList = objSeed.GetSeedByCity(searchOthers);
                    foreach (Seed sData in tmpSeedList)
                    {
                        seedData.Add(sData);
                    }
                }

             }

            string tmp = "";

            seedData = seedData.Distinct().Take(seedCounter).ToList();

            if (!string.IsNullOrEmpty(sortBy))
            {
                switch (sortBy)
                {
                    case "1":
                        seedData = seedData.OrderBy(x => x.Categories.FirstOrDefault() != null ? x.Categories.FirstOrDefault().name : "").ToList();
                        break;
                    case "2":
                        seedData = seedData.OrderBy(x => x.Location.zipcode).ToList();
                        break;
                    case "3":
                        seedData = seedData.OrderBy(x => x.title).ToList();
                        break;
                    default:
                        seedData = seedData.OrderBy(x => x.title).ToList();
                        break;
                }
            }

            string tmpCName = "";

            foreach (Seed s in seedData)
            {

                string imgPath = "No Image";

                int likesCount = s.Ratings.Where(x => x.likes.Equals("Like")).ToList().Count;
                int commitmentCount = s.Commitments.ToList().Count;
                int commentsCount = s.Comments.ToList().Count;

                if (s.Media != null && s.Media.Count > 0)
                {
                    imgPath = s.Media.FirstOrDefault().path;

                    imgPath = imgPath.Substring(imgPath.LastIndexOf('/'));

                    if (imgPath.Length > 1)
                        imgPath = System.Configuration.ConfigurationManager.AppSettings["RootURL"].ToString() + "/UploadedMedia" + imgPath;
                    else
                        imgPath = "No Image";
                }

                tmp += s.id.ToString() + "||" + s.title;

                if (s.Location.City != null)
                {
                    tmp += "||" + s.Location.City.name;
                }

                if (s.Location.City.Region != null)
                {
                    tmp += "||" + s.Location.City.Region.code;
                }

                if (s.Location != null)
                {
                    tmp += "||" + s.Location.zipcode;
                }

                tmp += "||" + imgPath;

                if (s.Categories != null && s.Categories.Count > 0)
                {
                    tmpCName = s.Categories.FirstOrDefault().name;
                }

                tmp += "||" + tmpCName;

                tmp += "||" + s.Member.firstName + " " + s.Member.lastName + "||" + s.Location.crossStreet + "||" + Convert.ToDateTime(s.createDate).ToString("dd MMMM yyyy") + "||" + s.description + "||" + likesCount + " Likes" + "||" + commitmentCount + " Commitments" + "||" + commentsCount + " Comments";

                string tmpCategory = "";
                foreach (Category c in s.Categories)
                {
                    if (tmpCategory.Length > 0)
                        tmpCategory = tmpCategory + "," + c.name;
                    else
                        tmpCategory = c.name;
                }
                tmp = tmp + "||" + tmpCategory;

                tmp += "##";

            }

            if (tmp.Length > 2)
                tmp = tmp.Substring(0, tmp.Length - 2);

            if (seedData.Count < 1)
                tmp = "No Matching Seeds Found";

            return tmp;
            #endregion
        }