Exemplo n.º 1
0
 public ActionResult EditCategory(string id, string name)
 {
     CategoryAction objCatg = new CategoryAction();
     if (!string.IsNullOrEmpty(name))
     {
         objCatg.UpdateCategory(name, id);
         return RedirectToAction("AddEditCategory", "Category");
     }
     else
     {
         ViewData["Result"] = "Please enter category name";
     }
     GetCategories();
     return View("AddEditCategory");
 }
Exemplo n.º 2
0
        public ActionResult ManageCategory()
        {
            CategoryAction objCatg = new CategoryAction();

            IList<Category> lstCategory = objCatg.GetAllCategories();

            for (int j = 0; j <= lstCategory.Count - 1; j++)
            {
                new Category() { id = lstCategory[j].id, name = lstCategory[j].name.ToString() };
            }

            var tList = new MultiSelectList(lstCategory, "id", "name");
            ViewData["CategoryList"] = tList;

            return View();
        }
Exemplo n.º 3
0
 public ActionResult InsertCategory(string name)
 {
     CategoryAction objCatg = new CategoryAction();
     Member memData = (Member) SessionStore.GetSessionValue(SessionStore.Memberobject);
     if (!string.IsNullOrEmpty(name))
     {
         string result = objCatg.AddCategory(name, memData.id.ToString());
         ViewData["Result"] = result;
         return RedirectToAction("AddEditCategory", "Category");
     }
     else
     {
         ViewData["Result"] = "Please enter category name";
     }
     GetCategories();
     return View("AddEditCategory");
 }
Exemplo n.º 4
0
 // *************************************
 // URL: /Category/ViewCategories
 // *************************************
 private void GetCategories()
 {
     CategoryAction objCatg = new CategoryAction();
     IList<Category> lstCategory = objCatg.GetAllCategories();
     ViewData["ListCategory"] = lstCategory;
 }
Exemplo n.º 5
0
 public ActionResult RequestCategory(string CategoryName)
 {
     CategoryAction objCategory = new CategoryAction();
     Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
     string result = objCategory.RequestCategory(CategoryName, memberData.id.ToString());
     if (!string.IsNullOrEmpty(result))
         ViewData["RequestCategory"] = result;
     return View();
 }
Exemplo n.º 6
0
        /// <summary>
        /// This method is used to Add new Seeds.
        /// </summary>
        /// <param name="SeedName"></param>
        /// <param name="Description"></param>
        /// <param name="CityName"></param>
        /// <param name="Street"></param>
        /// <param name="RegionCode"></param>
        /// <param name="LatLong"></param>
        /// <param name="ZipCode"></param>
        /// <param name="ownerId"></param>
        /// <param name="tagName"></param>
        /// <returns></returns>
        public string AddSeedData(string SeedName, string Description, string CityName, string Street, string RegionCode, string Lat, string Lng, string ZipCode, string ownerId, string tagName, string imageName, string categoryNames)
        {
            bool actionCompleted = false;
            Seed seedData = null;
            string imagePath = imageName;
            string result = "Error while seed planting.";
            try
            {
                SeedAction objSeed = new SeedAction();

                Seed objSeedEntity = new Seed();
                Member memberData = new Member();
                Tag objTagEntity = new Tag();

                objSeedEntity.title = SeedName.Replace("|","&");

                objSeedEntity.description = Description.Replace("|", "&");

                LocationAction objLocation = new LocationAction();
                string cityid = objLocation.GetCityIdByCityName(CityName, RegionCode);
                if (string.IsNullOrEmpty(cityid))
                    cityid = objSeed.AddCity(CityName, RegionCode);

                string lat = Lat;
                string longt = Lng;

                if (cityid.Length > 0)
                {
                    Location objLoc = objLocation.CreateLocation(cityid, (ZipCode).ToString(), Convert.ToDouble(lat), Convert.ToDouble(longt), Street);

                    objSeedEntity.locationId = new Guid(objLoc.id.ToString());

                    objSeedEntity.ownerId = new Guid(ownerId);
                    seedData = objSeed.AddSeed(objSeedEntity);

                    actionCompleted = true;
                    result = seedData.id.ToString();
                    if (!string.IsNullOrEmpty(tagName))
                    {
                        if (seedData.id != null && tagName.Length > 0)
                        {
                            if (!tagName.Equals("(null)"))
                            {
                                objTagEntity.name = tagName;
                                objTagEntity.seedId = seedData.id;
                                actionCompleted = objSeed.ManageTag(objTagEntity);
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(imageName))
                    {
                        if (!imageName.Equals("No Image"))
                        {
                            AddMedia("Iphone Image1", imageName, seedData.id.ToString(), "Image", ownerId);

                            imagePath = System.Configuration.ConfigurationManager.AppSettings["RootURL"].ToString() + "/UploadedMedia/" + imageName;
                        }
                    }
                    if (!string.IsNullOrEmpty(categoryNames))
                    {
                        if (seedData.id != null && categoryNames.Length > 0)
                        {
                            if (!categoryNames.Equals("Select Category"))
                            {
                                string[] arrCategoryIds;
                                string[] arrCategoryNames;
                                string ids = string.Empty;
                                //categoryNames = categoryNames.TrimStart(',');
                                arrCategoryNames = categoryNames.Split(',');
                                CategoryAction objCategory = new CategoryAction();
                                for (int c = 0; c < arrCategoryNames.Length; c++)
                                {
                                    if (!string.IsNullOrEmpty(ids))
                                        ids = ids + "," + objCategory.GetCategoryIdByCategoryName(arrCategoryNames[c].ToString().Trim());
                                    else
                                        ids = objCategory.GetCategoryIdByCategoryName(arrCategoryNames[c].ToString().Trim());
                                }
                                arrCategoryIds = ids.Split(',');
                                if (categoryNames.Trim().ToString() != "" && arrCategoryIds.Length > 0)
                                {
                                    objSeed.AddCategories(seedData.id.ToString(), arrCategoryIds);
                                }
                            }
                        }
                    }

                    result = seedData.id.ToString() + "||" + seedData.title + "||" + CityName + "||" + RegionCode + "||" + ZipCode + "||" + imageName + "||" + imagePath + "||" + DateTime.Now.ToString();
                }
                if (actionCompleted == false)
                {
                    result = "Error while seed planting.";
                }
            }
            catch (Exception ex)
            {
                result = "Error while seed planting.";
            }

            return result;
        }
Exemplo n.º 7
0
        public ActionResult ShareIdea1(string returnAction, string txtSeedTitle, string txtDesc, string seedCoordinates, string seedLocation, string txtCategory, IEnumerable<HttpPostedFileBase> mediaFiles)
        {
            #region codeRegion
            try
            {
                SeedAction objSeed = new SeedAction();
                LocationAction objLocation = new LocationAction();

                //Format address and create add seed model
                string[] splitAddress = seedLocation.Split(',');
                AddSeed seedData = new AddSeed();
                seedData.SeedName = txtSeedTitle;
                seedData.Description = txtDesc;
                seedData.LongLat = seedCoordinates;
                string seedCountry = string.Empty;
                if (splitAddress.Length > 4)
                {
                    seedData.StreetAddress = splitAddress[0].ToString() + ", " + splitAddress[1].ToString();
                    seedData.City = splitAddress[2].ToString().Trim();
                    string[] splitZipRegion = splitAddress[3].ToString().Trim().Split(' ');
                    seedData.ZipCode = splitZipRegion[1].ToString().Trim();
                    seedData.StateCode = splitZipRegion[0].ToString().Trim();
                    seedCountry = splitAddress[4].ToString();
                }
                else
                {
                    seedData.StreetAddress = splitAddress[0].ToString();
                    seedData.City = splitAddress[1].ToString().Trim();
                    string[] splitZipRegion = splitAddress[2].ToString().Trim().Split(' ');
                    seedData.ZipCode = splitZipRegion[1].ToString().Trim();
                    seedData.StateCode = splitZipRegion[0].ToString().Trim();
                    seedCountry = splitAddress[3].ToString();
                }
                //End formatting address

                if (seedCountry.Trim().Equals("USA") || seedCountry.Trim().Equals("US"))
                    seedCountry = seedCountry.Trim();
                else
                    throw new Exception("Seeds can not be planted outside region of United States");

                string plantedSeedId = AddSeedData(seedData);

                if (txtCategory != null)
                {
                    string catIds = string.Empty;
                    string[] splitCategories = txtCategory.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;
                        }
                    }
                    //bool isPlanted = false;
                    if (!string.IsNullOrEmpty(catIds))
                    {
                        string[] arrCatIds = catIds.Split(',');
                        objSeed.AddCategories(plantedSeedId, arrCatIds);
                    }
                }
                if (mediaFiles != null)
                {
                    foreach (var file in mediaFiles)
                    {
                        if (file.ContentLength > 0)
                        {
                            Bitmap sourceImage = new Bitmap(file.InputStream);
                            MediaManagement objMedia = new MediaManagement();
                            bool isMediaSaved = false;
                            int fileSize = file.ContentLength;
                            string fileOk = CheckFile(file.FileName, fileSize);
                            if (fileOk != "Invalid")
                            {
                                string strImgFileExtension = System.IO.Path.GetExtension(file.FileName);
                                DateTime datImg = DateTime.Now;
                                string ImgfileUploadtime = datImg.Day.ToString() + datImg.Month.ToString() + datImg.Year.ToString() + datImg.Hour.ToString() + datImg.Minute.ToString() + datImg.Second.ToString();
                                string filePath = Path.Combine(HttpContext.Server.MapPath("/UploadedMedia"), (plantedSeedId.ToString() + "_" + ImgfileUploadtime + strImgFileExtension));
                                objMedia.title = plantedSeedId.ToString() + "_" + ImgfileUploadtime;
                                objMedia.path = "../../UploadedMedia/" + (plantedSeedId.ToString() + "_" + ImgfileUploadtime + strImgFileExtension);
                                objMedia.type = fileOk;
                                objMedia.seedId = plantedSeedId;
                                sourceImage.Save(filePath, FileExtensionToImageFormat(filePath));
                                objMedia.embedScript = "Image Script";
                                isMediaSaved = SaveMediaInformation(objMedia);
                            }
                            else
                                throw new Exception("Please check file type or file size, Max Size Allowed : (Image : 2 MB) & (Video : 4 MB)");
                        }
                    }
                }
                Seed seed = GetSeedInformation(plantedSeedId);
                // Creating array list for token
                ArrayList arrTokens = new ArrayList();
                arrTokens.Add(seed.Member.firstName + " " + seed.Member.lastName);
                arrTokens.Add(seed.title);
                arrTokens.Add("http://" + Request.ServerVariables["SERVER_NAME"] + "/Seed/SeedDetails/" + seed.id);
                arrTokens.Add("http://" + Request.ServerVariables["SERVER_NAME"] + "/Member/Profile");

                // Filling mail object
                SendMail objSendMail = new SendMail();

                Regex rgxEmail = new Regex("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
                if (rgxEmail.IsMatch(seed.Member.username))
                    objSendMail.ToEmailId = seed.Member.username;
                else
                    objSendMail.ToEmailId = seed.Member.Email;
                objSendMail.Subject = "email.seedPlanted.subject.content";
                objSendMail.MsgBody = "email.seedPlanted.body.content";
                objSendMail.ChangesInMessage = arrTokens;

                objSendMail.SendEmail(objSendMail);

                return Redirect("/Seed/SeedDetails/" + seed.id);
            }
            catch (Exception ex)
            {
                SessionStore.SetSessionValue("PlantError", "Error occurred while planting seed#" + ex.Message.ToString());
                //ViewData["PlantErrMsg"] = ex.Message.ToString();
                return RedirectToAction("PlantError", "Seed");
            }
            #endregion
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        public ContentResult Category(string q, int limit, Int64 timestamp)
        {
            StringBuilder responseContentBuilder = new StringBuilder();
            CategoryAction objCat = new CategoryAction();
            IList<Category> lstCat = objCat.GetAllCategoriesByName(q).OrderBy(x => x.name).ToList();

            foreach (Category cat in lstCat)
                responseContentBuilder.Append(String.Format("{0}|{1}\n", cat.id, cat.name));

            return Content(responseContentBuilder.ToString());
        }
Exemplo n.º 10
0
        public ActionResult AddStream(string gTitle, string gDesc, string gIsPublic, string streamType, string seedLocationStreamMini, string seedCoordinatesStreamMini, string txtCategoryStreamMini, string isEdit, string StreamId)
        {
            #region Front Logic
            try
            {
                Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
                StreamAction objStream = new StreamAction();
                TempData["StreamTab"] = 1;
                if (isEdit == "Yes" && !string.IsNullOrEmpty(StreamId))
                {
                    ssStream ss = objStream.GetStreamById(StreamId);
                    ss.title = gTitle;
                    ss.description = gDesc;
                    ss.isPublic = Convert.ToBoolean(gIsPublic);
                    //Format address
                    string StreetAddress1 = string.Empty;
                    string City1 = string.Empty;
                    string ZipCode1 = string.Empty;
                    string StateCode1 = string.Empty;

                    if (!string.IsNullOrEmpty(seedLocationStreamMini))
                    {
                        string[] splitAddress = seedLocationStreamMini.Split(',');
                        if (splitAddress.Length > 4)
                        {
                            StreetAddress1 = splitAddress[0].ToString() + ", " + splitAddress[1].ToString();
                            City1 = splitAddress[2].ToString().Trim();
                            string[] splitZipRegion = splitAddress[3].ToString().Trim().Split(' ');
                            ZipCode1 = splitZipRegion[1].ToString().Trim();
                            StateCode1 = splitZipRegion[0].ToString().Trim();
                        }
                        else
                        {
                            StreetAddress1 = splitAddress[0].ToString();
                            City1 = splitAddress[1].ToString().Trim();
                            string[] splitZipRegion = splitAddress[2].ToString().Trim().Split(' ');
                            ZipCode1 = splitZipRegion[1].ToString().Trim();
                            StateCode1 = splitZipRegion[0].ToString().Trim();
                        }
                        //End formatting address

                        LocationAction objLocation = new LocationAction();
                        SeedAction objSeed = new SeedAction();
                        string latLong = seedCoordinatesStreamMini;
                        string[] strSplitLatLong = latLong.Split(',');
                        string lat = strSplitLatLong[0].ToString();
                        string longt = strSplitLatLong[1].ToString();
                        string crossStreet = StreetAddress1.Trim();
                        string cityId = objLocation.GetCityIdByCityName(City1, StateCode1);
                        if (string.IsNullOrEmpty(cityId))
                            cityId = objSeed.AddCity(City1, StateCode1);
                        Location loc = objLocation.CreateLocation(cityId, ZipCode1, Convert.ToDouble(lat), Convert.ToDouble(longt), crossStreet);
                        ss.locationId = loc.id;
                    }

                    ss = objStream.UpdateStream1(ss);
                    if (txtCategoryStreamMini != null)
                    {
                        string catIds = string.Empty;
                        string[] splitCategories = txtCategoryStreamMini.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");
                }

                ssStream stream = new ssStream();
                stream.title = gTitle;
                stream.description = gDesc;
                if (streamType == SystemStatements.STREAM_FEED)
                {
                    string defaultFeed = (string)SessionStore.GetSessionValue(SessionStore.DefaultFeed);
                    if (!string.IsNullOrEmpty(defaultFeed))
                        stream.criteria = defaultFeed;
                    stream.streamType = streamType;
                }
                else if (streamType == SystemStatements.STREAM_HANDPICKED)
                {
                    stream.streamType = streamType;
                }
                stream.ownerId = memberData.id;

                //Format address
                string StreetAddress = string.Empty;
                string City = string.Empty;
                string ZipCode = string.Empty;
                string StateCode = string.Empty;

                if (!string.IsNullOrEmpty(seedLocationStreamMini))
                {
                    string[] splitAddress = seedLocationStreamMini.Split(',');
                    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();
                    }
                    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();
                    }
                    //End formatting address

                    LocationAction objLocation = new LocationAction();
                    SeedAction objSeed = new SeedAction();
                    string latLong = seedCoordinatesStreamMini;
                    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 (txtCategoryStreamMini != null)
                {
                    string catIds = string.Empty;
                    string[] splitCategories = txtCategoryStreamMini.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 list#" + ex.Message.ToString());
                return RedirectToAction("PlantError", "Seed");
            }
            #endregion
        }
Exemplo n.º 11
0
        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
        }
Exemplo n.º 12
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
        }
Exemplo n.º 13
0
        /// <summary>
        /// This method is user to autenticate the member.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public string MemberAuthenticate(string UserName, string Password)
        {
            #region
            MemberAction objMember = new MemberAction();
            Member tmpData = objMember.Authenticate(UserName, Password);
            string result = "";
            string catResult = "";
            if (tmpData != null)
            {
                result = tmpData.id.ToString() + "##";
                CategoryAction objCategory = new CategoryAction();
                foreach (Category catData in objCategory.GetAllCategories())
                {
                    catResult += "||" + catData.name;
                }
                catResult = catResult.Substring(2);
                if (!string.IsNullOrEmpty(catResult))
                {
                    result = result + catResult;
                }

                string imgPath = "No Image";
                if (tmpData.MemberProfiles != null)
                {
                    MemberProfile memProfile = tmpData.MemberProfiles.FirstOrDefault();
                    if (memProfile != null)
                    {
                        imgPath = memProfile.imagePath;
                        imgPath = imgPath.Substring(imgPath.LastIndexOf('/'));
                        if (imgPath.Length > 1)
                            imgPath = System.Configuration.ConfigurationManager.AppSettings["RootURL"].ToString() + "/UploadedMedia" + imgPath;
                        else
                            imgPath = "No Image";
                    }
                }
                result = result + "##" + imgPath;
            }
            return result;
            #endregion
        }
Exemplo n.º 14
0
 public string GetAllCategories()
 {
     #region
     string result = "";
     CategoryAction objCategory = new CategoryAction();
     foreach (Category catData in objCategory.GetAllCategories())
     {
         result += "||" + catData.name;
     }
     result = result.Substring(2);
     return result;
     #endregion
 }
Exemplo n.º 15
0
        public ActionResult EditSeedInfo(string txtEdtSeedTitle, string txtEdtDesc, string seedCoordinatesEdt, string seedLocationEdt, string txtCategoryEdt, IEnumerable<HttpPostedFileBase> mediaFilesEdt, string EdtSeedID)
        {
            #region codeRegion
            try
            {
                SeedAction objSeed = new SeedAction();
                LocationAction objLocation = new LocationAction();

                Seed seed = GetSeedInformation(EdtSeedID);
                seed.title = txtEdtSeedTitle;
                string s = Regex.Replace(txtEdtDesc, @"<(.|\n)*?>", string.Empty);
                s = s.Replace("&nbsp;", " ");
                s = Regex.Replace(s, @"\s+", " ");
                s = Regex.Replace(s, @"\r\n", "\n");
                s = Regex.Replace(s, @"\n+", "\n");
                string description = s;

                badWordsFilter objWords = new badWordsFilter();
                string wordsFilePath = Server.MapPath("~/utils/badWords.xml");
                List<string> lstBadWords = badWordsFilter.BadWordList(ref wordsFilePath);
                description = objWords.FilterBadWords(lstBadWords, description);

                seed.description = description;

                Location loc = seed.Location;
                //Format address and create add seed model
                string[] splitAddress = seedLocationEdt.Split(',');
                string[] strSplitLatLong = seedCoordinatesEdt.Split(',');
                loc.localLat = Convert.ToDouble(strSplitLatLong[0].ToString());
                loc.localLong = Convert.ToDouble(strSplitLatLong[1].ToString());

                if (splitAddress.Length > 4)
                {
                    string[] splitZipRegion = splitAddress[3].ToString().Trim().Split(' ');
                    loc.crossStreet = splitAddress[0].ToString() + ", " + splitAddress[1].ToString();
                    string cityid = objLocation.GetCityIdByCityName(splitAddress[2].ToString().Trim(), splitZipRegion[0].ToString().Trim());
                    loc.cityId = new Guid(cityid);
                    loc.zipcode = splitZipRegion[1].ToString().Trim();
                }
                else
                {
                    string[] splitZipRegion = splitAddress[2].ToString().Trim().Split(' ');
                    loc.crossStreet = splitAddress[0].ToString();
                    string cityid = objLocation.GetCityIdByCityName(splitAddress[1].ToString().Trim(), splitZipRegion[0].ToString().Trim());
                    loc.cityId = new Guid(cityid);
                    loc.zipcode = splitZipRegion[1].ToString().Trim();
                }
                //End formatting address

                loc = objLocation.UpdateLocation(loc);
                seed.locationId = loc.id;
                seed = objSeed.UpdateSeed(seed);
                string plantedSeedId = seed.id.ToString();

                if (txtCategoryEdt != null)
                {
                    string catIds = string.Empty;
                    string[] splitCategories = txtCategoryEdt.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;
                        }
                    }
                    //bool isPlanted = false;
                    if (!string.IsNullOrEmpty(catIds))
                    {
                        string[] arrCatIds = catIds.Split(',');
                        objSeed.AddCategories(plantedSeedId, arrCatIds);
                    }
                }
                if (mediaFilesEdt != null)
                {
                    foreach (var file in mediaFilesEdt)
                    {
                        if (file.ContentLength > 0)
                        {
                            Bitmap sourceImage = new Bitmap(file.InputStream);
                            MediaManagement objMedia = new MediaManagement();
                            bool isMediaSaved = false;
                            int fileSize = file.ContentLength;
                            string fileOk = CheckFile(file.FileName, fileSize);
                            if (fileOk != "Invalid")
                            {
                                string strImgFileExtension = System.IO.Path.GetExtension(file.FileName);
                                DateTime datImg = DateTime.Now;
                                string ImgfileUploadtime = datImg.Day.ToString() + datImg.Month.ToString() + datImg.Year.ToString() + datImg.Hour.ToString() + datImg.Minute.ToString() + datImg.Second.ToString();
                                string filePath = Path.Combine(HttpContext.Server.MapPath("/UploadedMedia"), (plantedSeedId + "_" + ImgfileUploadtime + strImgFileExtension));
                                objMedia.title = plantedSeedId + "_" + ImgfileUploadtime;
                                objMedia.path = "../../UploadedMedia/" + (plantedSeedId + "_" + ImgfileUploadtime + strImgFileExtension);
                                objMedia.type = fileOk;
                                objMedia.seedId = plantedSeedId;
                                sourceImage.Save(filePath, FileExtensionToImageFormat(filePath));
                                objMedia.embedScript = "Image Script";
                                isMediaSaved = SaveMediaInformation(objMedia);
                            }
                            else
                                throw new Exception("Please check file type or file size, Max Size Allowed : (Image : 2 MB) & (Video : 4 MB)");
                        }
                    }
                }
                return Redirect("/Seed/SeedDetails/" + plantedSeedId);
            }
            catch (Exception ex)
            {
                SessionStore.SetSessionValue("PlantError", ex.Message.ToString());
                return RedirectToAction("PlantError", "Seed");
            }
            #endregion
        }
Exemplo n.º 16
0
        // *************************************
        // URL: /Seed/DiscoverSeed
        // *************************************
        public ActionResult DiscoverSeed(string cstreet, string city, string zip, string category, string keyword, string LatLongMaster, string byUser, string byRating)
        {
            #region
            string facebookLogin = (string)SessionStore.GetSessionValue(SessionStore.FacebookConnect);
            if (!string.IsNullOrEmpty(facebookLogin))
            {
                if (city == "City" || city == null)
                {
                    string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (string.IsNullOrEmpty(ip))
                    {
                        ip = Request.ServerVariables["REMOTE_ADDR"];
                    }

                    DataTable dtAddress = GetLocation(ip);
                    if (dtAddress != null)
                    {
                        if (dtAddress.Rows.Count > 0)
                        {
                            city = dtAddress.Rows[0]["City"].ToString();
                            if (string.IsNullOrEmpty(city))
                                city = "Phoenix";
                        }
                        else
                        {
                            city = "Phoenix";
                        }
                    }
                }
            }

            LocationAction objLocation = new LocationAction();
            SeedAction objSeed = new SeedAction();
            CategoryAction objCategory = new CategoryAction();

            string CatId = objCategory.GetCategoryIdByCategoryName(category);
            IList<Seed> listSeed = null;

            //Storing search result in session
            if (string.IsNullOrEmpty(cstreet) && string.IsNullOrEmpty(city) && string.IsNullOrEmpty(zip) && string.IsNullOrEmpty(category) && string.IsNullOrEmpty(keyword) && string.IsNullOrEmpty(LatLongMaster))
            {
                if (SessionStore.GetSessionValue(SessionStore.DiscoverSeed) != null)
                    listSeed = (IList<Seed>)SessionStore.GetSessionValue(SessionStore.DiscoverSeed);
            }
            else
            {
                listSeed = this.getSearchResult(cstreet, city, CatId, keyword, zip, byUser, byRating);
            }

            if (listSeed.Count > 0)
                SessionStore.SetSessionValue(SessionStore.DiscoverSeed, listSeed);

            string latlong = "";
            if (listSeed.Count > 0)
            {
                for (int i = 0; i < listSeed.Count; i++)
                {
                    if (latlong == "")
                    {
                        latlong = listSeed[i].Location.localLat + "," + listSeed[i].Location.localLong + "," + listSeed[i].title + "-<b>" + listSeed[i].status + "</b> <br />" + listSeed[i].Location.City.name + " " + listSeed[i].Location.zipcode + ",";
                    }
                    else
                    {
                        latlong += listSeed[i].Location.localLat + "," + listSeed[i].Location.localLong + "," + listSeed[i].title + "-<b>" + listSeed[i].status + "</b> <br />" + listSeed[i].Location.City.name + " " + listSeed[i].Location.zipcode + ",";
                    }
                }
            }
            Array late = latlong.Split(',');
            ViewData["LatLongCollection"] = latlong;
            if (listSeed.Count > 0)
                ViewData["ListSeed"] = listSeed;
            else
                ViewData["SearchMsg"] = "No matching seed found for your search criteria";

            return View();
            #endregion
        }
Exemplo n.º 17
0
        public ContentResult SearchHelp(string q, int limit, Int64 timestamp)
        {
            #region
            StringBuilder responseContentBuilder = new StringBuilder();
            CategoryAction objCat = new CategoryAction();
            StreamAction objStream = new StreamAction();
            LocationAction objLocation = new LocationAction();
            IList<Category> lstCat = objCat.GetAllCategoriesByName(q).OrderBy(x => x.name).ToList();
            IList<Member> lstMember = objStream.GetAllMembersByName(q).OrderBy(x => x.firstName).ToList();
            IList<City> lstCity = objLocation.GetAllCities(q).OrderBy(x => x.name).ToList();

            foreach (Category cat in lstCat)
                responseContentBuilder.Append(String.Format("{0}|{1}\n", cat.id, cat.name));

            foreach (Member mem in lstMember)
                responseContentBuilder.Append(String.Format("{0}|{1}\n", mem.id, mem.firstName));

            foreach (City ct in lstCity)
                responseContentBuilder.Append(String.Format("{0}|{1}\n", ct.id, ct.name));

            return Content(responseContentBuilder.ToString());
            #endregion
        }
Exemplo n.º 18
0
        /// <summary>
        /// This method is user to autenticate the member.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public IList<MemberLogin> MemberAuthenticate(string UserName, string Password)
        {
            IList<MemberLogin> lstMemberLogIn = new List<MemberLogin>();
            MemberLogin objMemberLogin = new MemberLogin();
            MemberAction objMember = new MemberAction();
            Member tmpData = objMember.Authenticate(UserName, Password);

            string catResult = "";
            if (tmpData != null)
            {
                objMemberLogin.MemberID = tmpData.id.ToString();
                CategoryAction objCategory = new CategoryAction();
                foreach (Category catData in objCategory.GetAllCategories())
                {
                    catResult += "||" + catData.name;
                }
                catResult = catResult.Substring(2);
                if (!string.IsNullOrEmpty(catResult))
                {
                    objMemberLogin.Categories = catResult;
                }

                string imgPath = "No Image";

                if (tmpData.MemberProfiles != null)
                {
                    MemberProfile memProfile = tmpData.MemberProfiles.FirstOrDefault();

                    if (memProfile != null)
                    {
                        imgPath = memProfile.imagePath;

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

                        if (imgPath.Length > 1)
                            imgPath = System.Configuration.ConfigurationManager.AppSettings["RootURL"].ToString() + "/UploadedMedia" + imgPath;
                        else
                            imgPath = "No Image";
                    }
                }
                objMemberLogin.MemberURL = imgPath;
                lstMemberLogIn.Add(objMemberLogin);
            }
            //result = result.Substring(2);
            return  lstMemberLogIn;
        }
Exemplo n.º 19
0
 public ActionResult ManageCategory(string[] Category)
 {
     CategoryAction objCatg = new CategoryAction();
     return View();
 }
Exemplo n.º 20
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;
        }
Exemplo n.º 21
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
        }
Exemplo n.º 22
0
        /// <summary>
        /// Method to Update seed.
        /// </summary>
        /// <param name="seedId"></param>
        /// <param name="seedName"></param>
        /// <param name="seedDescription"></param>
        /// <returns></returns>
        public string UpdateSeed(string seedId, string seedName, string seedDescription, string SeedTags, string categories, string imageName, string ownerId)
        {
            string isCompleted = "Error in Update Action";
            SeedAction objSeed = new SeedAction();

            try
            {
                Seed seedData = objSeed.GetSeedBySeedId(seedId);

                seedData.title = seedName.Replace("|", "&");
                seedData.description = seedDescription.Replace("|", "&");
                objSeed.UpdateSeed(seedData);

                if (!string.IsNullOrEmpty(imageName))
                {
                    if (!imageName.Equals("No Image"))
                    {
                        AddMedia("Iphone Image1", imageName, seedData.id.ToString(), "Image", ownerId);
                    }
                }
                if (!string.IsNullOrEmpty(categories))
                {
                    if (!categories.Equals("Select Category"))
                    {
                        bool isPlanted = false;
                        string[] arrCategoryIds;
                        string[] arrCategoryNames;
                        string ids = string.Empty;
                        arrCategoryNames = categories.Split(',');
                        CategoryAction objCategory = new CategoryAction();
                        for (int c = 0; c < arrCategoryNames.Length; c++)
                        {
                            if (!string.IsNullOrEmpty(ids))
                                ids = ids + "," + objCategory.GetCategoryIdByCategoryName(arrCategoryNames[c].ToString().Trim());
                            else
                                ids = objCategory.GetCategoryIdByCategoryName(arrCategoryNames[c].ToString().Trim());
                        }
                        arrCategoryIds = ids.Split(',');
                        if (categories.Trim().ToString() != "" && arrCategoryIds.Length > 0)
                        {
                            isPlanted = objSeed.AddCategories(seedData.id.ToString(), arrCategoryIds);
                        }
                    }
                }

                Tag objTagEntity = new Tag();
                if (!string.IsNullOrEmpty(SeedTags))
                {
                    if (!SeedTags.Equals("(null)"))
                    {
                        objTagEntity.name = SeedTags;
                        objTagEntity.seedId = new Guid(seedId);
                        objSeed.ManageTag(objTagEntity);
                    }
                }

                //isCompleted = "Seed Update Successfully";

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

                isCompleted = seedData.id.ToString() + "||" + seedData.title + "||" + seedData.Location.City.name + "||" + seedData.Location.City.Region.code + "||" + seedData.Location.zipcode + "||" + imageName;

                //isCompleted = "SeedId: " + seedId + ", Seed Name: " + seedName + ", Seed Description: " + seedDescription;
            }
            catch
            {

            }
            return isCompleted;
        }
Exemplo n.º 23
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();
        }
Exemplo n.º 24
0
        public string ShareIdea(string txtSeedTitle, string txtDesc, string seedCoordinates, string seedLocation, string txtCategory)
        {
            #region
            string returnMsg = string.Empty;
            try
            {
                SeedAction objSeed = new SeedAction();
                LocationAction objLocation = new LocationAction();

                //Format address and create add seed model
                string[] splitAddress = seedLocation.Split(',');
                AddSeed seedData = new AddSeed();
                seedData.SeedName = txtSeedTitle;
                seedData.Description = txtDesc;
                seedData.LongLat = seedCoordinates;
                if (splitAddress.Length > 4)
                {
                    seedData.StreetAddress = splitAddress[0].ToString() + ", " + splitAddress[1].ToString();
                    seedData.City = splitAddress[2].ToString().Trim();
                    string[] splitZipRegion = splitAddress[3].ToString().Trim().Split(' ');
                    seedData.ZipCode = splitZipRegion[1].ToString().Trim();
                    seedData.StateCode = splitZipRegion[0].ToString().Trim();
                }
                else
                {
                    seedData.StreetAddress = splitAddress[0].ToString();
                    seedData.City = splitAddress[1].ToString().Trim();
                    string[] splitZipRegion = splitAddress[2].ToString().Trim().Split(' ');
                    seedData.ZipCode = splitZipRegion[1].ToString().Trim();
                    seedData.StateCode = splitZipRegion[0].ToString().Trim();
                }
                //End formatting address

                string plantedSeedId = AddSeedData(seedData);

                if (txtCategory != null)
                {
                    string catIds = string.Empty;
                    string[] splitCategories = txtCategory.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(',');
                        objSeed.AddCategories(plantedSeedId, arrCatIds);
                    }
                }

                try
                {
                    // Get the HttpFileCollection
                    HttpFileCollectionBase hfc = Request.Files;
                    for (int i = 0; i < hfc.Count; i++)
                    {
                        if (hfc[i].ContentLength > 0)
                        {
                            hfc[i].SaveAs(Server.MapPath("UploadedMedia") + "\\" + System.IO.Path.GetFileName(hfc[i].FileName));
                        }
                    }
                }
                catch
                {

                }

                #region code to send mail
                Seed seed = GetSeedInformation(plantedSeedId);
                // Creating array list for token
                ArrayList arrTokens = new ArrayList();
                arrTokens.Add(seed.Member.firstName + " " + seed.Member.lastName);
                arrTokens.Add(seed.title);
                arrTokens.Add("http://" + Request.ServerVariables["SERVER_NAME"] + "/Seed/SeedDetails/" + seed.id);
                arrTokens.Add("http://" + Request.ServerVariables["SERVER_NAME"] + "/Member/Profile");

                // Filling mail object
                SendMail objSendMail = new SendMail();
                objSendMail.ToEmailId = seed.Member.username;
                objSendMail.Subject = "email.seedPlanted.subject.content";
                objSendMail.MsgBody = "email.seedPlanted.body.content";
                objSendMail.ChangesInMessage = arrTokens;

                objSendMail.SendEmail(objSendMail);
                #endregion

                returnMsg = "Seed has been planted successfully";
            }
            catch (Exception ex)
            {
                returnMsg = ex.Message.ToString();
            }

            return returnMsg;
            #endregion
        }