/// <summary> /// Method to add commitments. /// </summary> /// <param name="seedId"></param> /// <param name="memberId"></param> /// <param name="commitmentDate"></param> /// <param name="commitmentMsg"></param> /// <returns></returns> public bool addCommitment(string seedId, string memberId, string commitmentDate, string commitmentMsg) { #region bool actionDone = false; SeedAction objSeed = new SeedAction(); Seed seedData = objSeed.GetSeedBySeedId(seedId); seedData.status = SystemStatements.STATUS_GROWING; Commitment objCommit = new Commitment(); objCommit.id = Guid.NewGuid(); objCommit.commitDate = DateTime.Now; objCommit.deadline = Convert.ToDateTime(commitmentDate); objCommit.memberId = new Guid(memberId); objCommit.seedId = seedData.id; objCommit.status = SystemStatements.STATUS_ACTIVE; objCommit.msg = commitmentMsg; objCommit.isRead = false; seedData.Commitments.Add(objCommit); seedData = objSeed.UpdateSeed(seedData); if (seedData != null) actionDone = true; return actionDone; #endregion }
public ActionResult AddCommentAtHomePage(string SCid, string commentValue) { #region SeedAction objSeed = new SeedAction(); Seed seedData = objSeed.GetSeedBySeedId(SCid); seedData.status = SystemStatements.STATUS_GROWING; Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); Comment objComment = new Comment(); objComment.id = Guid.NewGuid(); objComment.commentDate = DateTime.Now; objComment.msg = commentValue; objComment.seedId = seedData.id; objComment.commentById = memberData.id; objComment.isRead = false; seedData.Comments.Add(objComment); objSeed.UpdateSeed(seedData); ContributionMailAlert((seedData.Member.firstName + " " + seedData.Member.lastName).ToString(), (memberData.firstName + " " + memberData.lastName).ToString(), seedData.title, ("http://" + Request.ServerVariables["SERVER_NAME"] + "/Seed/SeedDetails/" + seedData.id), seedData.Member.username.ToString(), "Comment"); ViewData["commentId"] = seedData.id; return PartialView("CommentPartial"); #endregion }
public void AddCommitment(string Sid, string Deadline, string Msg) { #region SeedAction objSeed = new SeedAction(); Seed seedData = objSeed.GetSeedBySeedId(Sid); seedData.status = SystemStatements.STATUS_GROWING; Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); Commitment objCommit = new Commitment(); objCommit.id = Guid.NewGuid(); objCommit.commitDate = DateTime.Now; objCommit.deadline = Convert.ToDateTime(Deadline); objCommit.memberId = memberData.id; objCommit.seedId = seedData.id; objCommit.status = SystemStatements.STATUS_ACTIVE; objCommit.msg = Msg; objCommit.isRead = false; seedData.Commitments.Add(objCommit); objSeed.UpdateSeed(seedData); MailForContribution((seedData.Member.firstName + " " + seedData.Member.lastName).ToString(), (memberData.firstName + " " + memberData.lastName).ToString(), seedData.title, ("http://" + Request.ServerVariables["SERVER_NAME"] + "/Member/UserDetail/" + memberData.id), seedData.Member.username.ToString(), "Commitment"); Response.Redirect("/Seed/SeedDetails/" + seedData.id); #endregion }
/// <summary> /// Method to add comments. /// </summary> /// <param name="seedId"></param> /// <param name="memberId"></param> /// <param name="commentMsg"></param> /// <returns></returns> public bool addComment(string seedId, string memberId, string commentMsg) { bool actionDone = false; SeedAction objSeed = new SeedAction(); Seed seedData = objSeed.GetSeedBySeedId(seedId); seedData.status = SystemStatements.STATUS_GROWING; Comment objComment = new Comment(); objComment.id = Guid.NewGuid(); objComment.commentDate = DateTime.Now; objComment.msg = commentMsg.Replace("|", "&"); objComment.seedId = seedData.id; objComment.commentById = new Guid(memberId); objComment.isRead = false; seedData.Comments.Add(objComment); seedData = objSeed.UpdateSeed(seedData); if (seedData != null) actionDone = true; return actionDone; }
/// <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; }
public void FlagSeed(string id, string FlagReason, string chkSpam, string chkWrgCat, string chkProhibited, string chkOther) { #region SeedAction objSeed = new SeedAction(); Seed sdata = objSeed.GetSeedBySeedId(id); Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); Flag flagdata = new Flag(); flagdata.id = Guid.NewGuid(); flagdata.dateFlagged = DateTime.Now; flagdata.flaggedById = memberData.id; flagdata.seedId = sdata.id; flagdata.reason = FlagReason; flagdata.isRead = false; if (!string.IsNullOrEmpty(chkSpam)) flagdata.isSpam = true; if (!string.IsNullOrEmpty(chkWrgCat)) flagdata.isWrongCategory = true; if (!string.IsNullOrEmpty(chkProhibited)) flagdata.isProhibited = true; if (!string.IsNullOrEmpty(chkOther)) flagdata.isOther = true; sdata.Flags.Add(flagdata); objSeed.UpdateSeed(sdata); SessionStore.SetSessionValue(SessionStore.SeedFlagged, "FlagTrue"); ContributionMail((memberData.firstName + " " + memberData.lastName).ToString(), sdata.title, System.Configuration.ConfigurationManager.AppSettings["AdminMail"].ToString(), "Flag"); Response.Redirect("/Seed/SeedDetails/" + sdata.id); #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 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 void AddToFavorite(string id) { #region SeedAction objSeed = new SeedAction(); Seed seedData = objSeed.GetSeedBySeedId(id); Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); Bookmark objBookMark = new Bookmark(); objBookMark.id = Guid.NewGuid(); objBookMark.seedId = seedData.id; objBookMark.memberId = memberData.id; if (objSeed.GetBookmarkList(memberData.id.ToString(), seedData.id.ToString())) { seedData.Bookmarks.Add(objBookMark); objSeed.UpdateSeed(seedData); } Response.Redirect("/Seed/SeedDetails/" + seedData.id); #endregion }
public string jsFlagSeed(string id, string FlagReason, string chkSpam, string chkWrgCat, string chkProhibited, string chkOther) { #region Boolean isFlagged = false; SeedAction objSeed = new SeedAction(); Seed sdata = objSeed.GetSeedBySeedId(id); Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); Flag flagdata = new Flag(); flagdata.id = Guid.NewGuid(); flagdata.dateFlagged = DateTime.Now; flagdata.flaggedById = memberData.id; flagdata.seedId = sdata.id; flagdata.reason = FlagReason; flagdata.isRead = false; if (!string.IsNullOrEmpty(chkSpam)) flagdata.isSpam = true; if (!string.IsNullOrEmpty(chkWrgCat)) flagdata.isWrongCategory = true; if (!string.IsNullOrEmpty(chkProhibited)) flagdata.isProhibited = true; if (!string.IsNullOrEmpty(chkOther)) flagdata.isOther = true; sdata.Flags.Add(flagdata); sdata = objSeed.UpdateSeed(sdata); isFlagged = true; ContributionMail((memberData.firstName + " " + memberData.lastName).ToString(), sdata.title, System.Configuration.ConfigurationManager.AppSettings["AdminMail"].ToString(), "Flag"); JavaScriptSerializer serializer = new JavaScriptSerializer(); var output = serializer.Serialize(isFlagged); return output; #endregion }
public string AddSeedComment(string txtComment, string Sid) { #region Boolean isAuthenticate = false; SeedAction objSeed = new SeedAction(); Seed seedData = objSeed.GetSeedBySeedId(Sid); Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); Comment objComment = new Comment(); objComment.id = Guid.NewGuid(); objComment.commentDate = DateTime.Now; objComment.msg = txtComment; objComment.seedId = seedData.id; objComment.commentById = memberData.id; seedData.Comments.Add(objComment); seedData = objSeed.UpdateSeed(seedData); if (seedData.Comments != null) isAuthenticate = true; JavaScriptSerializer serializer = new JavaScriptSerializer(); var output = serializer.Serialize(isAuthenticate); return output; #endregion }