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
        }
 public ActionResult AddSeed(AddSeed objAddSeedModel)
 {
     if (ModelState.IsValid)
     {
         SessionStore.SetSessionValue(SessionStore.SeedModel, objAddSeedModel);
         return RedirectToAction("SetCategory", "Seed");
     }
     else
     {
         return View(objAddSeedModel);
     }
 }
        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
        }
        public ActionResult SetCategory(string seedId, string categoryIds, AddSeed objAddSeedModel)
        {
            #region
            if (ModelState.IsValid)
            {
                try
                {
                    SeedAction objSeed = new SeedAction();
                    LocationAction objLocation = new LocationAction();
                    AddSeed seedData = (AddSeed)objAddSeedModel;

                    string[] arrCategoryIds;
                    string latLong = seedData.LongLat;
                    char[] separator = new char[] { ',' };
                    string[] strSplitLatLong = latLong.Split(separator);
                    string lat = strSplitLatLong[0].ToString();
                    string longt = strSplitLatLong[1].ToString();
                    categoryIds = categoryIds.TrimStart(',');
                    arrCategoryIds = categoryIds.Split(',');

                    string plantedSeedId = AddSeedData(seedData);
                    bool isPlanted = false;
                    if (categoryIds.Trim().ToString() != "")
                    {
                        isPlanted = objSeed.AddCategories(plantedSeedId, arrCategoryIds);
                    }
                    bindCheckBox(plantedSeedId);
                    Seed seed = GetSeedInformation(plantedSeedId);

                    #region Send Mail
                    // 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

                    return Redirect("/Seed/SeedDetails/" + seed.id);
                }
                catch (Exception ex)
                {
                    ViewData["SeedPlant"] = ex.Message.ToString();
                }
            }
            miniDashboard();
            bindCategory();
            RegionCode();
            return View("../Member/Dashboard");
            #endregion
        }
 public ActionResult SeedInfo(AddSeed objAddSeed, string categoryIds)
 {
     SessionStore.SetSessionValue(SessionStore.SeedInfo, objAddSeed);
     SessionStore.SetSessionValue(SessionStore.CategoryId, categoryIds);
     return RedirectToAction("SeedLocation", "Seed");
 }
        public ActionResult PlantSeed(string seedTitle, string description, string info, string address, string keyword, string categoryIds)
        {
            #region
            try
            {
                SeedAction objSeed = new SeedAction();
                LocationAction objLocation = new LocationAction();

                //Format address and create add seed model
                string[] splitAddress = address.Split(',');
                AddSeed seedData = new AddSeed();
                seedData.SeedName = seedTitle;

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

                seedData.Description = description;
                seedData.LongLat = info;
                seedData.Tag = keyword;
                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[] arrCategoryIds;
                string latLong = seedData.LongLat;
                char[] separator = new char[] { ',' };
                string[] strSplitLatLong = latLong.Split(separator);
                string lat = strSplitLatLong[0].ToString();
                string longt = strSplitLatLong[1].ToString();
                categoryIds = categoryIds.TrimStart(',');
                arrCategoryIds = categoryIds.Split(',');

                string plantedSeedId = AddSeedData(seedData);
                bool isPlanted = false;
                if (categoryIds.Trim().ToString() != "")
                {
                    isPlanted = objSeed.AddCategories(plantedSeedId, arrCategoryIds);
                }
                bindCheckBox(plantedSeedId);

                Seed seed = GetSeedInformation(plantedSeedId);

                #region Send Mail
                // 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

                return Redirect("/Seed/SeedDetails/" + seed.id);
            }
            catch (Exception ex)
            {
                ViewData["SeedPlant"] = ex.Message.ToString();
            }
            bindCategory();
            return View();
            #endregion
        }
        public string AddSeedData(AddSeed objAddSeedModel)
        {
            #region
            bool actionCompleted = false;
            Seed seedData = null;
            SeedAction objSeed = new SeedAction();

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

            objSeedEntity.title = objAddSeedModel.SeedName;
            if (!string.IsNullOrEmpty(objAddSeedModel.rootSeedId))
                objSeedEntity.rootSeedID = new Guid(objAddSeedModel.rootSeedId);

            if (!string.IsNullOrEmpty(objAddSeedModel.parentSeedId))
                objSeedEntity.parentSeedID = new Guid(objAddSeedModel.parentSeedId);

            string s = Regex.Replace(objAddSeedModel.Description, @"<(.|\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;

            if (description.Length > 999)
                description = description.Substring(0, 995);

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

            objSeedEntity.description = description;

            LocationAction objLocation = new LocationAction();
            string cityid = objLocation.GetCityIdByCityName(objAddSeedModel.City, objAddSeedModel.StateCode);
            if (string.IsNullOrEmpty(cityid))
                cityid = objSeed.AddCity(objAddSeedModel.City, objAddSeedModel.StateCode);

            if (string.IsNullOrEmpty(cityid))
                throw new Exception("Please select associated state and city");
            string latLong = objAddSeedModel.LongLat;
            char[] separator = new char[] { ',' };
            string[] strSplitLatLong = latLong.Split(separator);
            string lat = strSplitLatLong[0].ToString();
            string longt = strSplitLatLong[1].ToString();
            string crossStreet = objAddSeedModel.StreetAddress.Trim();
            Location objLoc = objLocation.CreateLocation(cityid, (objAddSeedModel.ZipCode).ToString(), Convert.ToDouble(lat), Convert.ToDouble(longt), crossStreet);

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

            if (SeedSpeak.Util.SessionStore.GetSessionValue(SeedSpeak.Util.SessionStore.Memberobject) != null)
                memberData = (Member)SeedSpeak.Util.SessionStore.GetSessionValue(SeedSpeak.Util.SessionStore.Memberobject);
            objSeedEntity.ownerId = memberData.id;
            seedData = objSeed.AddSeed(objSeedEntity);

            if (objSeedEntity.id != null)
            {
                if (!string.IsNullOrEmpty(objAddSeedModel.Tag))
                {
                    objTagEntity.name = objAddSeedModel.Tag;
                    objTagEntity.seedId = objSeedEntity.id;
                    actionCompleted = objSeed.ManageTag(objTagEntity);
                }
            }
            if (actionCompleted == false)
            {
                ModelState.AddModelError("", "Error while seed planting.");
                RedirectToAction("AddSeed", "Seed");
            }

            return seedData.id.ToString();
            #endregion
        }