Пример #1
0
        public ActionResult Default(string addr, string criteria, string[] sel0, string searchCriteriaTxt, string btnNext, string btnPrevious, string postLat, string postLng, string postZip)
        {
            GetTopPlanters();

            ViewData["LocLat"] = postLat;
            ViewData["LocLng"] = postLng;

            #region fb Coding
            string appid = ConfigurationManager.AppSettings["AppID"];
            ViewData["AppID"] = ConfigurationManager.AppSettings["AppID"];

            Repository repoObj = new Repository();
            Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
            if (memberData != null)
            {

            }
            else
            {
                FacebookConnect fbConnect = new FacebookConnect();
                if (fbConnect.IsConnected)
                {
                    // message = "You are connected to Facebook";

                    //Use the wrapper class to get the access token
                    string token = fbConnect.AccessToken;
                    //Alternatively you can just pull the accesstoken out directly with the following line
                    //string token = HttpContext.Request.Cookies["fbs_" + ConfigurationManager.AppSettings["AppID"]]["\"access_token"];

                    //Note - you need to decode the token or it will be encoded twice.
                    token = HttpUtility.UrlDecode(token);

                    FacebookAPI api = new FacebookAPI(token);
                    JSONObject me = api.Get("/" + fbConnect.UserID);
                    SessionStore.SetSessionValue(SessionStore.FacebookConnect, "FacebookUserLoggedIn");

                    return RedirectToAction("DiscoverSeed", "Seed");
                }
                else
                {

                }
            }
            #endregion

            #region Search Code
            //Category Selected Seeds
            Session["SelectedCategory"] = null;
            str = sel0;
            string myChoise = null;
            if (sel0 != null)
            {
                for (int i = 0; i < sel0.Length; i++)
                {
                    if (i == 0)
                    {
                        myChoise = sel0[0];
                    }
                    else
                    {
                        myChoise = myChoise + "," + sel0[i];
                    }
                }
            }
            Session["SelectedCategory"] = myChoise;

            ViewData["SelectedCategory"] = Session["SelectedCategory"];
            if (sel0 != null)
            {
                if (sel0.Count() == 1 && sel0[0].ToString().Equals("all"))
                    Session["SelectedCategory"] = null;
            }
            #endregion

            #region Home Page Paging
            if (btnNext == ".." || btnPrevious == ".")
            {
                int PageCount = Convert.ToInt32(Session["PageCount"]);
                int rowCount = Convert.ToInt32(Session["RowCount"]);
                int NoOfPage = rowCount / 10;
                if (rowCount % 10 != 0)
                {
                    NoOfPage += 1;
                }

                IList<Seed> lstseed = (IList<Seed>)SessionStore.GetSessionValue(SessionStore.DiscoverSeed);
                if (btnNext != null && btnNext == "..")
                {
                    int skipRecord = PageCount * 10;
                    IList<Seed> lst = lstseed.Skip(skipRecord).ToList();
                    ViewData["SeedList"] = lst.Take(10).ToList();
                    PageCount += 1;
                    Session["PageCount"] = PageCount;
                    if (PageCount == NoOfPage)
                    {
                        ViewData["NxtVisibility"] = "visibility:hidden;";
                        ViewData["PrevVisibility"] = "visibility:visible;";
                    }
                }
                else if (btnPrevious != null && btnPrevious == ".")
                {
                    int takeRecord = (PageCount - 1) * 10;
                    IList<Seed> lst = lstseed.Take(takeRecord).ToList();
                    ViewData["SeedList"] = lst.Reverse().Take(10).Reverse().ToList();
                    PageCount -= 1;
                    if (PageCount == 1)
                    {
                        ViewData["NxtVisibility"] = "visibility:visible;";
                        ViewData["PrevVisibility"] = "visibility:hidden;";
                    }
                    Session["PageCount"] = PageCount;
                }

                ViewData["MarkerList"] = MarkerGenerator((IList<Seed>)ViewData["SeedList"]);
                return View();
            }
            #endregion

            #region Search Logic
            if (addr != "" || criteria != "" || sel0 != null)
            {
                string categList = string.Empty;
                if (sel0 != null)
                {
                    if (sel0.Count() == 1 && sel0[0].ToString().Equals("all"))
                    {
                        categList = "all";
                    }
                    else if (sel0.Count() > 0 && !sel0[0].ToString().Equals("all"))
                    {
                        for (int c = 0; c < sel0.Count(); c++)
                        {
                            if (string.IsNullOrEmpty(categList))
                                categList = "'" + sel0[c].ToString() + "'";
                            else
                                categList = categList + ",'" + sel0[c].ToString() + "'";
                        }
                    }
                    else if (sel0.Count() > 1 && sel0[0].ToString().Equals("all"))
                    {
                        for (int c = 1; c < sel0.Count(); c++)
                        {
                            if (string.IsNullOrEmpty(categList))
                                categList = "'" + sel0[c].ToString() + "'";
                            else
                                categList = categList + ",'" + sel0[c].ToString() + "'";
                        }
                    }
                }

                //Neighborhood
                try
                {
                    if (!string.IsNullOrEmpty(addr))
                    {
                        if (!addr.Contains(','))
                        {
                            string[] checkString = addr.Trim().Split(' ');
                            if (checkString.Length > 1)
                            {
                                int splitCount = checkString.Count();
                                if (checkString[splitCount - 1].ToString().Length == 2)
                                {
                                    int idx = addr.LastIndexOf(' ');
                                    string idxString = addr.Insert(idx, ",");
                                    addr = idxString;
                                }
                            }
                        }
                    }
                }
                catch { }

                string[] splitString1 = addr.Split(',');
                string cityName1 = string.Empty;
                if (splitString1.Length > 0)
                {
                    string citySplit = splitString1[0].ToString();
                    if (citySplit.Contains("Your Location"))
                        citySplit = citySplit.Replace("Your Location : ", "");

                    cityName1 = citySplit;
                }
                ViewData["CatLocation"] = cityName1;
                IList<Seed> newListSeed = this.getHomeSearchResult(cityName1, categList, criteria, postZip, criteria);
                ViewData["SeedList"] = newListSeed.Distinct().ToList();

                if (newListSeed.Count > 0)
                {
                    ViewData["SeedList"] = newListSeed.OrderByDescending(x => x.createDate).ToList();
                }
                else
                {
                    newListSeed = repoObj.List<Seed>().Where(x => (x.status.Equals(SystemStatements.STATUS_NEW) || x.status.Equals(SystemStatements.STATUS_GROWING))).Take(20).OrderByDescending(x => x.createDate).ToList();
                    ViewData["SeedList"] = newListSeed;
                    ViewData["CitySearchMsg"] = "<span>Sorry, no seeds planted in '" + cityName1 + "' area. Showing latest additions.</span>";
                    string streamFeed = "Select top 20 * from Seed order by createDate desc";
                    SessionStore.SetSessionValue(SessionStore.DefaultFeed, streamFeed);
                }

                if (newListSeed.Count > 0)
                    SessionStore.SetSessionValue(SessionStore.DiscoverSeed, newListSeed);
                Session["RowCount"] = newListSeed.Count();
                Session["PageCount"] = "1";
                ViewData["PrevVisibility"] = "visibility:hidden;";
                if (newListSeed.Count > 10)
                    ViewData["NxtVisibility"] = "visibility:visible;";
                else
                    ViewData["NxtVisibility"] = "visibility:hidden;";

                CommonMethods objCmnMethods = new CommonMethods();
                string locLatLng = Session["LocLatLng"].ToString();
                string[] locLatLngSplit = locLatLng.Split(',');
                foreach (Seed sd in newListSeed)
                {
                    sd.seedDistance = (int)objCmnMethods.distance(Convert.ToDouble(locLatLngSplit[0].ToString()), Convert.ToDouble(locLatLngSplit[1].ToString()), Convert.ToDouble(sd.Location.localLat), Convert.ToDouble(sd.Location.localLong));
                }
                if (newListSeed.Count > 0)
                    SessionStore.SetSessionValue(SessionStore.DiscoverSeed, newListSeed);
                ViewData["SeedList"] = newListSeed.OrderBy(x => x.seedDistance).ToList();
                ViewData["MarkerList"] = MarkerGenerator(newListSeed);
                ViewData["Criteria"] = criteria;

                if (newListSeed.Count > 0)
                {
                    CategoryAction objCat = new CategoryAction();
                    IList<Category> categ = new List<Category>();
                    Category c = null;
                    foreach (Seed s in newListSeed)
                    {
                        IList<Category> listCategory = s.Categories.ToList();
                        if (listCategory.Count > 0)
                        {
                            foreach (Category c1 in listCategory)
                            {
                                c = objCat.GetCategoryById(s.Categories.FirstOrDefault().id.ToString());
                                if (c != null)
                                    categ.Add(c);
                            }
                        }
                    }
                    ViewData["SeedCategories"] = categ.Distinct().ToList();
                }
            }
            #endregion

            return View();
        }
Пример #2
0
        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
        }
Пример #3
0
        public ActionResult Default()
        {
            #region PreviousCoding
            Repository repoObj = new Repository();
            Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
            if (memberData != null)
            {
                //ViewData["LocationData"] = locations;
                //ViewData["Memberlocation"] = memberLocation;
            }
            else
            {
                string logoutString = TempData["Logout"] as string;
                if (logoutString != "Logout")
                {
                    const string myFacebookApiKey = "101151816623334";
                    const string myFacebookSecret = "65f49046dce2d1f54d6991e43c4af675";

                    var connectSession = new ConnectSession(myFacebookApiKey, myFacebookSecret);
                    if (connectSession.IsConnected())
                    {
                        ViewData["FBConnected"] = true;
                        var api = new Api(connectSession);
                        ViewData["FBUser"] = api.Users.GetInfo();
                        ViewData["UserID"] = api.Users.GetInfo().uid;
                        SessionStore.SetSessionValue(SessionStore.FacebookConnect, "FacebookUserLoggedIn");
                        string[] fbDetails = new string[2];
                        fbDetails[0] = Convert.ToString("fb_" + api.Users.GetInfo().uid);
                        fbDetails[1] = api.Users.GetInfo().name;
                        SessionStore.SetSessionValue("FacebookDetails", fbDetails);
                        api.Session.Logout();
                        connectSession.Logout();
                        return RedirectToAction("FBUser", "Member");
                    }
                }
            }
            #endregion

            GetTopPlanters();

            CommonMethods objCmnMethods = new CommonMethods();

            string strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress;
            if (strIpAddress == "127.0.0.1")
                strIpAddress = "61.246.241.162";

            string citySearch = string.Empty;
            string stateSearch = string.Empty;
            string zipCodeSearch = string.Empty;
            string latSearch = string.Empty;
            string lngSearch = string.Empty;
            string[] currentAddress;

            string ipLocation = objCmnMethods.MaxMindIPData(strIpAddress);
            if (!string.IsNullOrEmpty(ipLocation) && (!ipLocation.Contains("IP_NOT_FOUND")))
            {
                //IPaddressAPI
                currentAddress = ipLocation.Split(',');

                if (string.IsNullOrEmpty(currentAddress[1].Replace("\"", "").ToString()))
                    stateSearch = "AZ";
                else
                {
                    stateSearch = currentAddress[1].Replace("\"", "").ToString();
                    //stateSearch = "WA";
                }

                if (string.IsNullOrEmpty(currentAddress[2].ToString()))
                    citySearch = "Phoenix";
                else
                {
                    citySearch = currentAddress[2].Replace("\"", "").ToString();
                    //citySearch = "Seattle";
                }

                if (string.IsNullOrEmpty(currentAddress[3].Replace("\"", "").ToString()))
                {
                    //zipCodeSearch = "85027";
                    SeedAction objS = new SeedAction();
                    LocationAction objLocation = new LocationAction();
                    string cityId = objLocation.GetCityIdByCityName(citySearch, stateSearch);
                    zipCodeSearch = objS.GetZipOfSeedByCityId(cityId);
                }
                else
                    zipCodeSearch = currentAddress[3].Replace("\"", "").ToString();

                latSearch = currentAddress[4].Replace("\"", "").ToString();
                lngSearch = currentAddress[5].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();
            }

            ViewData["LocLat"] = latSearch;
            ViewData["LocLng"] = lngSearch;
            Session["LocLatLng"] = latSearch + "," + lngSearch;

            SeedAction objSeed = new SeedAction();
            IList<Seed> lstSeed = getHomeSearchResult(citySearch, "", "", zipCodeSearch, "");
            if (lstSeed.Count > 0)
            {
                ViewData["SeedList"] = lstSeed.OrderByDescending(x => x.createDate).ToList();
                ViewData["userLocation"] = "Your Location : " + citySearch + ", " + stateSearch;
                ViewData["CatLocation"] = citySearch + ", " + stateSearch;
            }
            else
            {
                lstSeed = repoObj.List<Seed>().Where(x => x.status.Equals(SystemStatements.STATUS_NEW) || x.status.Equals(SystemStatements.STATUS_GROWING)).OrderByDescending(x => x.createDate).Take(20).ToList();
                ViewData["SeedList"] = lstSeed;
                ViewData["userLocation"] = "Your Location : " + citySearch + ", " + stateSearch;
                ViewData["CatLocation"] = citySearch + ", " + stateSearch;
                ViewData["CitySearchMsg"] = "<span>Sorry, no seeds planted in '" + citySearch + "' area. Showing latest additions.</span>";
                string streamFeed = "Select top 20 * from Seed order by createDate desc";
                SessionStore.SetSessionValue(SessionStore.DefaultFeed, streamFeed);
            }

            string advSearch = TempData["DiscoverSeed"] as string;
            if (advSearch != "AdvanceSearch")
            {
                if (lstSeed.Count > 0)
                    SessionStore.SetSessionValue(SessionStore.DiscoverSeed, lstSeed);
            }

            if (SessionStore.GetSessionValue(SessionStore.DiscoverSeed) != null)
                lstSeed = (IList<Seed>)SessionStore.GetSessionValue(SessionStore.DiscoverSeed);

            int rowCount = lstSeed.Count;
            Session["RowCount"] = rowCount;
            Session["PageCount"] = "1";
            ViewData["SeedList"] = lstSeed.Take(10).ToList();
            ViewData["PrevVisibility"] = "visibility:hidden;";
            if (lstSeed.Count > 10)
                ViewData["NxtVisibility"] = "visibility:visible;";
            else
                ViewData["NxtVisibility"] = "visibility:hidden;";

            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));
            }
            if (lstSeed.Count > 0)
                SessionStore.SetSessionValue(SessionStore.DiscoverSeed, lstSeed);
            ViewData["SeedList"] = lstSeed.OrderBy(x => x.seedDistance).ToList();

            ViewData["MarkerList"] = MarkerGenerator((IList<Seed>)ViewData["SeedList"]);

            //ListBox
            if (Session["SelectedCategory"] != null)
            {
                Session["SelectedCategory"] = null;
            }
            else
            {
                if (str != null)
                {
                    string myString = null;
                    for (int i = 0; i < str.Length; i++)
                    {
                        if (i == 0)
                        {
                            myString = str[i];

                        }
                        else
                        {
                            myString = myString + "," + str[i];
                        }
                    }
                    Session["SelectedCategory"] = myString;
                    ViewData["SelectedCategories"] = myString;
                }
            }
            //ListBox
            if (lstSeed.Count > 0)
            {
                CategoryAction objCat = new CategoryAction();
                IList<Category> categ = new List<Category>();
                Category c = null;
                foreach (Seed s in lstSeed)
                {
                    IList<Category> listCategory = s.Categories.ToList();
                    if (listCategory.Count > 0)
                    {
                        foreach (Category c1 in listCategory)
                        {
                            c = objCat.GetCategoryById(s.Categories.FirstOrDefault().id.ToString());
                            if (c != null)
                                categ.Add(c);
                        }
                    }
                }
                ViewData["SeedCategories"] = categ.Distinct().ToList();
            }

            return View();
        }
Пример #4
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
        }
Пример #5
0
        public IList<Seed> ProximitySort()
        {
            IList<Seed> listSeed = null;
            string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
            if (ip == "127.0.0.1")
                ip = "61.246.241.162";

            CommonMethods objCmnMethods = new CommonMethods();
            //MaxMind
            string zipSearch = string.Empty;
            string[] currentAddress = objCmnMethods.IP2AddressMaxMind().Split('\'');
            if (currentAddress[15].ToString() == "")
                zipSearch = "85027";

            listSeed = getHomeSearchResult("", "", "", zipSearch, "");
            return listSeed;
        }
Пример #6
0
        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
        }
Пример #7
0
        public IList<Seed> getHomeSearchResult(string city, string catId, string keyword, string zip, string userName)
        {
            #region Logic
            IList<Seed> seedList = new List<Seed>();
            Repository repoObj = new Repository();
            SeedAction objSeed = new SeedAction();

            string searchString = "";
            if (catId != null && catId.Length > 0)
            {
                searchString = "select distinct seed.* from seed, Seed_has_Category where (status='New' or status='Growing')";
            }
            else
            {
                searchString = "select distinct seed.* from seed where (status='New' or status='Growing')";
            }
            bool flag = false;

            #region Search in location table
            if ((!string.IsNullOrEmpty(city) && city != "Set Your location") || (!string.IsNullOrEmpty(zip) && zip != "Zipcode"))
            {
                searchString += " and locationid in ( select distinct(id) from location where ";
                if (city.Length > 0 && city != "City")
                {
                    if (!string.IsNullOrEmpty(zip))
                        searchString += "cityid in (select id from City where name = '" + city + "' )";
                    else
                        searchString += "cityid in (select id from City where name = '" + city + "' ))";
                    flag = true;
                }

                if (!string.IsNullOrEmpty(zip))
                {
                    if (zip.Length > 0 && zip != "Zipcode")
                    {
                        CommonMethods cmnMethod = new CommonMethods();
                        string zipResult = cmnMethod.GetZipByRadiusNew("25", zip);
                        if (flag)
                        {
                            searchString += " or ";
                        }

                        if (!string.IsNullOrEmpty(zipResult))
                        {
                            searchString = searchString.Substring(0, searchString.Length - 1);
                            searchString += " zipcode in (" + zipResult + "))";
                        }
                        else
                        {
                            searchString += " zipcode in (" + zip + "))";
                        }

                        flag = true;
                    }
                }
            }
            #endregion

            #region Search according to categories
            if (catId != null && catId.Length > 0)
            {
                if (!catId.Equals("all"))
                    searchString += " and Seed_has_Category.categoryId in (" + catId + ") and Seed.id=Seed_has_Category.seedId";
            }
            #endregion

            #region Search in username, firstname, lastname
            if (!string.IsNullOrEmpty(userName))
            {
                if (userName != "Search by user, category, keywords")
                {
                    if (userName.Contains('@'))
                    {
                        searchString += " and Seed.ownerId in (Select id from Member where username = '******')";
                    }
                    else
                    {
                        string fName = string.Empty;
                        string lName = string.Empty;
                        string[] splt = userName.Split(' ');
                        if (splt.Count() > 1)
                        {
                            fName = splt[0].ToString();
                            lName = splt[1].ToString();
                            searchString += " and Seed.ownerId in (select id from Member where firstName = '" + fName + "' or lastName='" + lName + "')";
                        }
                        else
                        {
                            fName = splt[0].ToString();
                            searchString += " and Seed.ownerId in (select id from Member where firstName = '" + fName + "')";
                        }
                    }
                }
            }
            #endregion

            #region Search in title or description
            if (!string.IsNullOrEmpty(keyword))
            {
                if (keyword.Length > 0 && keyword != "Search by user, category, keywords")
                {
                    searchString += " or (Seed.title like '%" + keyword + "%' or Seed.description like '%" + keyword + "%')";
                }
            }
            #endregion

            seedList = repoObj.ListPPP<Seed>("usp_SearchSeeds", searchString).ToList();
            IList<Seed> returnSeedList = (from s in seedList select s).Distinct().ToList();
            SessionStore.SetSessionValue(SessionStore.DefaultFeed, searchString);
            return returnSeedList;
            #endregion
        }
Пример #8
0
        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 AddStreamFeed(string gFeedTitle, string gFeedDesc, string gIsPublic, string seedLocationStreamFeed, string seedCoordinatesStreamFeed, string txtCategoryStreamFeed, string feedLocation, string profileLocValue, string NewLocValue, string LocationRadius, string CoordinatesRadius, string gIsMedia, string txtIncludeTerms, string txtExcludeTerms, string isEdit, string StreamId)
        {
            #region Front Logic
            try
            {
                Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
                StreamAction objStream = new StreamAction();
                ssStream stream = new ssStream();
                stream.title = gFeedTitle;
                stream.description = gFeedDesc;

                string feedQuery = "Select Seed.* from Seed where (seed.[status] = 'New' or seed.[status] = 'Growing')";

                #region add location in query
                if (!string.IsNullOrEmpty(feedLocation))
                {
                    if (feedLocation != "AllLocations")
                    {
                        string radius = string.Empty;
                        string radiusZipList = string.Empty;
                        string ZipCodeFeed = string.Empty;
                        if (feedLocation == "ProfileLocation")
                        {
                            radius = profileLocValue;
                            if (memberData.MemberProfiles != null)
                            {
                                if (memberData.MemberProfiles.FirstOrDefault().Location.zipcode != null)
                                    ZipCodeFeed = Convert.ToString(memberData.MemberProfiles.FirstOrDefault().Location.zipcode);
                            }
                            else
                                ZipCodeFeed = "85027";
                        }
                        if (feedLocation == "NewLocation")
                        {
                            radius = NewLocValue;

                            //Format address
                            string[] splitAddressFeed = LocationRadius.Split(',');
                            if (splitAddressFeed.Length > 4)
                            {
                                string[] splitZipRegion = splitAddressFeed[3].ToString().Trim().Split(' ');
                                ZipCodeFeed = splitZipRegion[1].ToString().Trim();
                            }
                            else
                            {
                                string[] splitZipRegion = splitAddressFeed[2].ToString().Trim().Split(' ');
                                ZipCodeFeed = splitZipRegion[1].ToString().Trim();
                            }
                            //End formatting address
                        }

                        //Get zip codes according to radius
                        CommonMethods objCommon = new CommonMethods();
                        radiusZipList = objCommon.GetZipByRadius(radius, ZipCodeFeed);
                        //End get zip codes according to radius

                        if (string.IsNullOrEmpty(radiusZipList))
                            radiusZipList = ZipCodeFeed;

                        feedQuery += " and locationId in (Select id from Location where zipcode in (" + radiusZipList + "))";
                    }
                }
                #endregion

                #region include terms in query
                if (!string.IsNullOrEmpty(txtIncludeTerms))
                {
                    string inCondition = string.Empty;
                    string[] includeTerms = txtIncludeTerms.Split(',');
                    for (int i = 0; i < includeTerms.Length; i++)
                    {
                        if (i == 0)
                            inCondition = "'" + includeTerms[i].ToString() + "'";
                        else
                            inCondition += ",'" + includeTerms[i].ToString() + "'";
                    }
                    feedQuery += " 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(txtExcludeTerms))
                {
                    string exCondition = string.Empty;
                    string[] excludeTerms = txtExcludeTerms.Split(',');
                    for (int i = 0; i < excludeTerms.Length; i++)
                    {
                        if (i == 0)
                            exCondition = "'" + excludeTerms[i].ToString() + "'";
                        else
                            exCondition += ",'" + excludeTerms[i].ToString() + "'";
                    }
                    feedQuery += " 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(gIsMedia))
                {
                    switch (gIsMedia)
                    {
                        case "All":
                            feedQuery += " and Seed.id in (Select m.seedId from Media m)";
                            break;
                        case "NoMedia":
                            feedQuery += " and Seed.id not in (Select m.seedId from Media m)";
                            break;
                        case "PhotosOnly":
                            feedQuery += " and Seed.id in (Select m.seedId from Media m where m.[type]='" + SystemStatements.MEDIA_IMAGE + "')";
                            break;
                        case "VideosOnly":
                            feedQuery += " and Seed.id in (Select m.seedId from Media m where m.[type]='" + SystemStatements.MEDIA_VIDEO + "')";
                            break;
                        default:
                            break;
                    }
                }
                #endregion

                stream.criteria = feedQuery;
                stream.streamType = SystemStatements.STREAM_FEED;
                stream.ownerId = memberData.id;

                if (isEdit == "Yes" && !string.IsNullOrEmpty(StreamId))
                {
                    ssStream ss = objStream.GetStreamById(StreamId);
                    ss.title = gFeedTitle;
                    ss.description = gFeedDesc;
                    ss.criteria = feedQuery;
                    ss.isPublic = Convert.ToBoolean(gIsPublic);
                    if (!string.IsNullOrEmpty(seedLocationStreamFeed))
                    {
                        //Format address
                        string StreetAddress = string.Empty;
                        string City = string.Empty;
                        string ZipCode = string.Empty;
                        string StateCode = string.Empty;
                        string[] splitAddress = seedLocationStreamFeed.Split(',');
                        string feedCountry = string.Empty;
                        if (splitAddress.Length > 4)
                        {
                            StreetAddress = splitAddress[0].ToString() + ", " + splitAddress[1].ToString();
                            City = splitAddress[2].ToString().Trim();
                            string[] splitZipRegion = splitAddress[3].ToString().Trim().Split(' ');
                            ZipCode = splitZipRegion[1].ToString().Trim();
                            StateCode = splitZipRegion[0].ToString().Trim();
                            feedCountry = splitAddress[4].ToString();
                        }
                        else
                        {
                            StreetAddress = splitAddress[0].ToString();
                            City = splitAddress[1].ToString().Trim();
                            string[] splitZipRegion = splitAddress[2].ToString().Trim().Split(' ');
                            ZipCode = splitZipRegion[1].ToString().Trim();
                            StateCode = splitZipRegion[0].ToString().Trim();
                            feedCountry = splitAddress[3].ToString();
                        }
                        //End formatting address
                        if (feedCountry.Trim().Equals("USA") || feedCountry.Trim().Equals("US"))
                            feedCountry = feedCountry.Trim();
                        else
                            throw new Exception("Feeds can not be created outside region of United States");

                        LocationAction objLocation = new LocationAction();
                        SeedAction objSeed = new SeedAction();
                        string latLong = seedCoordinatesStreamFeed;
                        string[] strSplitLatLong = latLong.Split(',');
                        string lat = strSplitLatLong[0].ToString();
                        string longt = strSplitLatLong[1].ToString();
                        string crossStreet = StreetAddress.Trim();
                        string cityId = objLocation.GetCityIdByCityName(City, StateCode);
                        if (string.IsNullOrEmpty(cityId))
                            cityId = objSeed.AddCity(City, StateCode);
                        Location loc = objLocation.CreateLocation(cityId, ZipCode, Convert.ToDouble(lat), Convert.ToDouble(longt), crossStreet);
                        ss.locationId = loc.id;
                    }
                    ss = objStream.UpdateStream1(ss);
                    if (txtCategoryStreamFeed != null)
                    {
                        string catIds = string.Empty;
                        string[] splitCategories = txtCategoryStreamFeed.Split(',');
                        for (int i = 0; i < splitCategories.Length; i++)
                        {
                            CategoryAction objCatg = new CategoryAction();
                            string idCatg = objCatg.GetCategoryIdByCategoryName(splitCategories[i].ToString());
                            if (!string.IsNullOrEmpty(idCatg))
                            {
                                if (string.IsNullOrEmpty(catIds))
                                    catIds = idCatg;
                                else
                                    catIds = catIds + "," + idCatg;
                            }
                        }
                        if (!string.IsNullOrEmpty(catIds))
                        {
                            string[] arrCatIds = catIds.Split(',');
                            objStream.AddFeedCategories(Convert.ToString(ss.id), arrCatIds);
                        }
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString(ss.id)))
                    {
                        return RedirectToAction("ManageMyFeeds", "SeedStream");
                    }
                    return RedirectToAction("UnexpectedError", "Error");
                }

                if (!string.IsNullOrEmpty(seedLocationStreamFeed))
                {
                    //Format address
                    string StreetAddress = string.Empty;
                    string City = string.Empty;
                    string ZipCode = string.Empty;
                    string StateCode = string.Empty;
                    string[] splitAddress = seedLocationStreamFeed.Split(',');
                    string feedCountry = string.Empty;
                    if (splitAddress.Length > 4)
                    {
                        StreetAddress = splitAddress[0].ToString() + ", " + splitAddress[1].ToString();
                        City = splitAddress[2].ToString().Trim();
                        string[] splitZipRegion = splitAddress[3].ToString().Trim().Split(' ');
                        ZipCode = splitZipRegion[1].ToString().Trim();
                        StateCode = splitZipRegion[0].ToString().Trim();
                        feedCountry = splitAddress[4].ToString();
                    }
                    else
                    {
                        StreetAddress = splitAddress[0].ToString();
                        City = splitAddress[1].ToString().Trim();
                        string[] splitZipRegion = splitAddress[2].ToString().Trim().Split(' ');
                        ZipCode = splitZipRegion[1].ToString().Trim();
                        StateCode = splitZipRegion[0].ToString().Trim();
                        feedCountry = splitAddress[3].ToString();
                    }
                    //End formatting address
                    if (feedCountry.Trim().Equals("USA") || feedCountry.Trim().Equals("US"))
                        feedCountry = feedCountry.Trim();
                    else
                        throw new Exception("Feeds can not be created outside region of United States");

                    LocationAction objLocation = new LocationAction();
                    SeedAction objSeed = new SeedAction();
                    string latLong = seedCoordinatesStreamFeed;
                    string[] strSplitLatLong = latLong.Split(',');
                    string lat = strSplitLatLong[0].ToString();
                    string longt = strSplitLatLong[1].ToString();
                    string crossStreet = StreetAddress.Trim();
                    string cityId = objLocation.GetCityIdByCityName(City, StateCode);
                    if (string.IsNullOrEmpty(cityId))
                        cityId = objSeed.AddCity(City, StateCode);
                    Location loc = objLocation.CreateLocation(cityId, ZipCode, Convert.ToDouble(lat), Convert.ToDouble(longt), crossStreet);
                    stream.locationId = loc.id;
                }
                stream.isPublic = Convert.ToBoolean(gIsPublic);

                stream = objStream.CreateStream1(stream);
                if (txtCategoryStreamFeed != null)
                {
                    string catIds = string.Empty;
                    string[] splitCategories = txtCategoryStreamFeed.Split(',');
                    for (int i = 0; i < splitCategories.Length; i++)
                    {
                        CategoryAction objCatg = new CategoryAction();
                        string idCatg = objCatg.GetCategoryIdByCategoryName(splitCategories[i].ToString());
                        if (!string.IsNullOrEmpty(idCatg))
                        {
                            if (string.IsNullOrEmpty(catIds))
                                catIds = idCatg;
                            else
                                catIds = catIds + "," + idCatg;
                        }
                    }
                    if (!string.IsNullOrEmpty(catIds))
                    {
                        string[] arrCatIds = catIds.Split(',');
                        objStream.AddFeedCategories(Convert.ToString(stream.id), arrCatIds);
                    }
                }
                if (!string.IsNullOrEmpty(Convert.ToString(stream.id)))
                {
                    return RedirectToAction("ManageMyFeeds", "SeedStream");
                }
                return RedirectToAction("UnexpectedError", "Error");
            }
            catch (Exception ex)
            {
                SessionStore.SetSessionValue("PlantError", "Error occurred while creating feed#" + ex.Message.ToString());
                return RedirectToAction("PlantError", "Seed");
            }
            #endregion
        }
Пример #10
0
        /// <summary>
        /// Method to get list of seeds by zip
        /// </summary>
        /// <param name="radius"></param>
        /// <param name="zip"></param>
        /// <returns></returns>
        public IList<Seed> GetAllSeedsByZip(string radius, string zip)
        {
            #region Business Logic

            IList<Seed> seedData = new List<Seed>();

            try
            {
                CommonMethods commMethods = new CommonMethods();

                DataTable allZipCodes = commMethods.GetZipListByRadiusNew(radius, zip);

                //string abc = commMethods.GetZipByRadius(radius, zip);

                IList<Location> locationList = repoObj.List<Location>().ToList();

                IList<Location> FilterZip =
                 (from u in locationList
                 join p in allZipCodes.AsEnumerable() on u.zipcode
                 equals p.Field<string>("Zip").Trim().ToUpper()
                 select u).Distinct().ToList();

                //seedData = repoObj.List<Location>(x => x.zipcode.Equals(zip) && (x.status.Equals(SystemStatements.STATUS_NEW) || x.status.Equals(SystemStatements.STATUS_GROWING))).ToList();

               // IList<Location> locationList = repoObj.List<Location>(x => x.zipcode.Equals(zip)).ToList();

                foreach (Location l in FilterZip)
                {
                    if (l.Seeds != null && l.Seeds.Count > 0)
                    {
                        seedData.Add(l.Seeds.FirstOrDefault());
                    }
                    //foreach (Seed s in l.Seeds)
                    //{
                        //if (s.status.Equals(SystemStatements.STATUS_NEW) || s.status.Equals(SystemStatements.STATUS_GROWING))
                        //{

                       // }ss
                    //}
                }
            }

            catch (Exception ex)
            {
                WriteError(ex);
            }
            return seedData;
            #endregion
        }
Пример #11
0
        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");
        }
Пример #12
0
        /// <summary>
        /// Method to get stream by zip
        /// </summary>
        /// <param name="zip"></param>
        /// <returns></returns>
        public IList<ssStream> GetAllStreamByZip(string zip)
        {
            #region Business Logic
            IList<ssStream> streamData = new List<ssStream>();
            try
            {
                CommonMethods commMethods = new CommonMethods();
                DataTable allZipCodes = commMethods.GetZipListByRadius("25", zip);
                IList<Location> locationList = repoObj.List<Location>().ToList();
                IList<Location> FilterZip =
                 (from u in locationList
                  join p in allZipCodes.AsEnumerable() on u.zipcode
                  equals p.Field<string>("Zip").Trim().ToUpper()
                  select u).Distinct().ToList();

                foreach (Location loc in FilterZip)
                {
                    if (loc.ssStreams != null && loc.ssStreams.Count > 0)
                    {
                        streamData.Add(loc.ssStreams.FirstOrDefault());
                    }
                }
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
            return streamData;
            #endregion
        }