/// <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; }
/// <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; }
public ActionResult EditSeed(string SeedId, string SeedTitle, string SeedDescription, string SeedTags, string categoryIds) { #region SeedAction objSeed = new SeedAction(); Seed seed = objSeed.GetSeedBySeedId(SeedId); seed.title = SeedTitle; badWordsFilter objWords = new badWordsFilter(); string filePath = Server.MapPath("~/utils/badWords.xml"); List<string> lstBadWords = badWordsFilter.BadWordList(ref filePath); string description = objWords.FilterBadWords(lstBadWords, SeedDescription); if (description.Length > 999) description = description.Substring(0, 995); seed.description = description; seed = objSeed.UpdateSeed(seed); string[] arrCategoryIds; char[] separator = new char[] { ',' }; categoryIds = categoryIds.TrimStart(','); arrCategoryIds = categoryIds.Split(','); bool isPlanted = false; if (categoryIds.Trim().ToString() != "") { isPlanted = objSeed.AddCategories(SeedId, arrCategoryIds); } Tag objTagEntity = new Tag(); if (!string.IsNullOrEmpty(SeedTags)) { objTagEntity.name = SeedTags; objTagEntity.seedId = new Guid(SeedId); objSeed.ManageTag(objTagEntity); } if (seed.id != null) { //send automated email - content of email will be decided later // Creating array list for token ArrayList arrTokens = new ArrayList(); arrTokens.Add(seed.Member.firstName + " " + seed.Member.lastName); arrTokens.Add(seed.title); // Filling mail object SendMail objSendMail = new SendMail(); objSendMail.ToEmailId = seed.Member.username; objSendMail.Subject = "email.editSeed.subject.content"; objSendMail.MsgBody = "email.editSeed.body.content"; objSendMail.ChangesInMessage = arrTokens; objSendMail.SendEmail(objSendMail); } Response.Redirect("/Seed/SeedDetails/" + SeedId); return View(); #endregion }
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(" ", " "); 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 }
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 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 SeedLocation(string InfoLatLong, string seedLocation) { #region try { SeedAction objSeed = new SeedAction(); LocationAction objLocation = new LocationAction(); //Format address and create add seed model string[] splitAddress = seedLocation.Split(','); AddSeed seedData = (AddSeed)SessionStore.GetSessionValue(SessionStore.SeedInfo); seedData.LongLat = InfoLatLong; 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 categoryIds = (string)SessionStore.GetSessionValue(SessionStore.CategoryId); 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 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 }