/// <summary> /// Method for Change Member Password. /// </summary> /// <param name="member"></param> /// <param name="newPasswd"></param> /// <returns></returns> public bool ChangeMemberPasswd(Member member, string newPassword) { #region Business Logic bool updated = false; try { //Get the current member object from session member.passwd = Security.Encrypt(newPassword, true); repoObj.Update<Member>(member); updated = true; } catch (Exception ex) { WriteError(ex); } return updated; #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(" ", " "); 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 }
private void FixupMember(Member previousValue) { if (previousValue != null && previousValue.Flags.Contains(this)) { previousValue.Flags.Remove(this); } if (Member != null) { if (!Member.Flags.Contains(this)) { Member.Flags.Add(this); } if (flaggedById != Member.id) { flaggedById = Member.id; } } else if (!_settingFK) { flaggedById = null; } }
/// <summary> /// Method to update member. /// </summary> /// <param name="member"></param> /// <returns></returns> public bool UpdateMember(Member member) { #region Business Logic bool isUpdated = false; try { repoObj.Update<Member>(member); isUpdated = true; } catch (Exception ex) { WriteError(ex); } return isUpdated; #endregion }
/// <summary> /// Method to signup for new users. /// </summary> /// <param name="rmodel"></param> /// <returns></returns> public bool Signup(RegisterModel rmodel) { #region Business Logic bool actionCompleted = false; Member member = null; try { member = new Member(); member.id = Guid.NewGuid(); member.username = rmodel.UserName; member.passwd = Security.Encrypt(rmodel.Password, true); member.firstName = rmodel.FirstName; member.lastName = rmodel.LastName; member.secretQ = rmodel.SecretQuestion; member.secretA = rmodel.SecretAnswer; member.status = SystemStatements.STATUS_ACTIVE; member.created = DateTime.Now; member.roleId = repoObj.List<Role>(x => x.name == SystemStatements.ROLE_END_USER).FirstOrDefault().id; member.isVerified = false; member.organisationName = rmodel.organisationName; member.Email = rmodel.UserName; repoObj.Create<Member>(member); actionCompleted = true; } catch (Exception ex) { WriteError(ex); } return actionCompleted; #endregion }
/// <summary> /// Method to update member info /// </summary> /// <param name="memData"></param> /// <returns></returns> public bool UpdateMemberInfoByService(Member memData) { #region Business Logic Member memberData = GetMemberByMemberId(memData.id.ToString()); bool updated = false; try { memberData.firstName = memData.firstName; memberData.lastName = memData.lastName; memberData.organisationName = memData.organisationName; repoObj.Update<Member>(memberData); updated = true; } catch (Exception ex) { WriteError(ex); } return updated; #endregion }
private void FixupMember(Member previousValue) { if (previousValue != null && previousValue.Media.Contains(this)) { previousValue.Media.Remove(this); } if (Member != null) { if (!Member.Media.Contains(this)) { Member.Media.Add(this); } if (uploadedById != Member.id) { uploadedById = Member.id; } } else if (!_settingFK) { uploadedById = null; } }
private void FixupMember(Member previousValue) { if (previousValue != null && previousValue.MemberReplySeeds.Contains(this)) { previousValue.MemberReplySeeds.Remove(this); } if (Member != null) { if (!Member.MemberReplySeeds.Contains(this)) { Member.MemberReplySeeds.Add(this); } if (memberID != Member.id) { memberID = Member.id; } } else if (!_settingFK) { memberID = null; } }
/// <summary> /// Method to manage External Members. /// </summary> /// <param name="externalAccount"></param> /// <returns></returns> public bool ManageExternalAccount(Member member, ExternalAccount externalAccount) { #region Business Logic bool actionCompleted = false; try { ExternalAccount externalAccountData = null; //see if ExternalAccount exists externalAccountData = repoObj.List<ExternalAccount>(x => x.accountTye.Equals(externalAccount.accountTye) && x.username.Equals(externalAccount.username)).FirstOrDefault(); if (externalAccountData != null) { externalAccountData.passwd = externalAccountData.passwd; repoObj.Update<ExternalAccount>(externalAccountData); } else { externalAccountData = new ExternalAccount(); externalAccountData.id = Guid.NewGuid(); externalAccountData.accountTye = externalAccount.accountTye; externalAccountData.username = externalAccount.username; externalAccountData.passwd = externalAccount.passwd; externalAccountData.verified = false; externalAccountData.memberId = member.id; repoObj.Create<ExternalAccount>(externalAccountData); } actionCompleted = true; } catch (Exception ex) { WriteError(ex); } return actionCompleted; #endregion }
/// <summary> /// Method to get members user is following /// </summary> /// <param name="memberId"></param> /// <returns></returns> public IList<Member> GetFollowing(string memberId) { #region Business Logic Guid id = new Guid(memberId); IList<FollowPeople> followerList = null; IList<Member> memberList = new List<Member>(); try { followerList = repoObj.List<FollowPeople>(x => x.Member.id.Equals(id)).ToList(); foreach (var fl in followerList) { Member mem = new Member(); mem = repoObj.List<Member>(x => x.id.Equals(fl.Member1.id)).FirstOrDefault(); memberList.Add(mem); } } catch (Exception ex) { WriteError(ex); } return memberList; #endregion }
/// <summary> /// Method to get list of mute members /// </summary> /// <param name="memberId"></param> /// <returns></returns> public IList<Member> GetMuteMembersByMemberId(string memberId) { #region Business Logic Guid id = new Guid(memberId); IList<MutePeople> MuteList = null; IList<Member> memberList = new List<Member>(); try { MuteList = repoObj.List<MutePeople>(x => x.Member.id.Equals(id)).ToList(); foreach (var ml in MuteList) { Member mem = new Member(); mem = repoObj.List<Member>(x => x.id.Equals(ml.Member.id)).FirstOrDefault(); memberList.Add(mem); } } catch (Exception ex) { WriteError(ex); } return memberList; #endregion }
/// <summary> /// Method to upload profile image /// </summary> /// <param name=""></param> /// <returns></returns> public bool UploadProfileImage(Member member, string imagePath) { #region Business Logic bool updated = false; try { //see if member.MemberProfile is empty //if empty create new //if exists, update MemberProfile memberProfileData = repoObj.List<MemberProfile>(x => x.Member.id.Equals(member.id)).FirstOrDefault(); if (memberProfileData == null) { memberProfileData = new MemberProfile(); memberProfileData.id = Guid.NewGuid(); memberProfileData.memberId = member.id; memberProfileData.imagePath = imagePath; repoObj.Create<MemberProfile>(memberProfileData); } else { memberProfileData.imagePath = imagePath; repoObj.Update<MemberProfile>(memberProfileData); } updated = true; } catch (Exception ex) { WriteError(ex); } return updated; #endregion }
/// <summary> /// Method to signup for new users via facebook. /// </summary> /// <param name="rmodel"></param> /// <returns></returns> public bool FBSignup(string userName, string fname, string lname, string email) { #region Business Logic bool actionCompleted = false; Member member = null; try { member = new Member(); member.id = Guid.NewGuid(); member.username = userName; member.firstName = fname; member.lastName = lname; member.status = SystemStatements.STATUS_ACTIVE; member.created = DateTime.Now; member.roleId = repoObj.List<Role>(x => x.name == SystemStatements.ROLE_END_USER).FirstOrDefault().id; member.isVerified = false; member.Email = email; repoObj.Create<Member>(member); actionCompleted = true; } catch (Exception ex) { WriteError(ex); } return actionCompleted; #endregion }
/// <summary> /// Method to Update Member profile. /// </summary> /// <param name="member"></param> /// <param name="sex"></param> /// <param name="dob"></param> /// <param name="location"></param> /// <returns></returns> public bool UpdateMemberProfile(Member member, string sex, DateTime dob, Location location, string url, string bio) { #region Business Logic bool updated = false; try { //see if member.MemberProfile is empty //if empty create new //if exists, update MemberProfile memberProfileData = repoObj.List<MemberProfile>(x => x.Member.id.Equals(member.id)).FirstOrDefault(); if (memberProfileData == null) { memberProfileData = new MemberProfile(); memberProfileData.id = Guid.NewGuid(); memberProfileData.locationId = location.id; memberProfileData.memberId = member.id; memberProfileData.sex = sex; memberProfileData.setURL = url; memberProfileData.bio = bio; repoObj.Create<MemberProfile>(memberProfileData); } else { memberProfileData.sex = sex; memberProfileData.locationId = location.id; memberProfileData.setURL = url; memberProfileData.bio = bio; repoObj.Update<MemberProfile>(memberProfileData); } updated = true; } catch (Exception ex) { WriteError(ex); } return updated; #endregion }
/// <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; }
/// <summary> /// Method to Manage Member Privacy. /// </summary> /// <param name="privacy"></param> /// <returns></returns> public bool ManageMemberPrivacy(Member member, Privacy privacy) { #region Business Logic bool actionCompleted = false; try { Privacy privacyData = null; //see if Privacy Setting exists privacyData = repoObj.List<Privacy>(x => x.Member.id.Equals(member.id)).FirstOrDefault(); if (privacyData != null) { privacyData.viewUsername = privacy.viewUsername; privacyData.seedContribution = privacy.seedContribution; privacyData.seedCommitment = privacy.seedCommitment; privacyData.viewLocation = privacy.viewLocation; privacyData.webNotification = privacy.webNotification; privacyData.devicePush = privacy.devicePush; privacyData.emailNotification = privacy.emailNotification; privacyData.autoTweet = privacy.autoTweet; repoObj.Update<Privacy>(privacyData); } else { privacyData = new Privacy(); privacyData.id = Guid.NewGuid(); privacyData.memberId = member.id; privacyData.viewUsername = privacy.viewUsername; privacyData.seedContribution = privacy.seedContribution; privacyData.seedCommitment = privacy.seedCommitment; privacyData.viewLocation = privacy.viewLocation; privacyData.webNotification = privacy.webNotification; privacyData.devicePush = privacy.devicePush; privacyData.emailNotification = privacy.emailNotification; privacyData.autoTweet = privacy.autoTweet; repoObj.Create<Privacy>(privacyData); } actionCompleted = true; } catch (Exception ex) { WriteError(ex); } return actionCompleted; #endregion }
private void FixupMember(Member previousValue) { if (previousValue != null && previousValue.ssStreams.Contains(this)) { previousValue.ssStreams.Remove(this); } if (Member != null) { if (!Member.ssStreams.Contains(this)) { Member.ssStreams.Add(this); } if (ownerId != Member.id) { ownerId = Member.id; } } else if (!_settingFK) { ownerId = null; } }
/// <summary> /// Method to Manage Member Profile. /// </summary> /// <param name="cityName"></param> /// <param name="zipcode"></param> /// <param name="localLat"></param> /// <param name="localLong"></param> /// <param name="regionName"></param> /// <param name="sex"></param> /// <param name="dob"></param> /// <returns></returns> public bool ManageMemberProfile(Member member, string cityId, string zipcode, double localLat, double localLong, string sex, DateTime dob, string url, string bio) { #region Business Logic bool actionCompleted = false; try { LocationAction lrepo = new LocationAction(); //Get the location Location location = lrepo.CreateLocation(cityId, zipcode, localLat, localLong, ""); //Updates the member profile this.UpdateMemberProfile(member, sex, dob, location, url, bio); actionCompleted = true; } catch (Exception ex) { WriteError(ex); } return actionCompleted; #endregion }
private void FixupMember(Member previousValue) { if (previousValue != null && previousValue.ExternalAccounts.Contains(this)) { previousValue.ExternalAccounts.Remove(this); } if (Member != null) { if (!Member.ExternalAccounts.Contains(this)) { Member.ExternalAccounts.Add(this); } if (memberId != Member.id) { memberId = Member.id; } } else if (!_settingFK) { memberId = null; } }
/// <summary> /// Check if old Password Match. /// </summary> /// <param name="oldPassword"></param> /// <returns></returns> public bool CheckOldPassword(Member member, string oldPassword) { #region Business Logic bool IsAuthenticate = false; //Get the current member object from session try { if (Security.Encrypt(oldPassword, true).Equals(member.passwd)) { IsAuthenticate = true; } } catch (Exception ex) { WriteError(ex); } return IsAuthenticate; #endregion }
private void FixupMember1(Member previousValue) { if (previousValue != null && previousValue.MutePeoples1.Contains(this)) { previousValue.MutePeoples1.Remove(this); } if (Member1 != null) { if (!Member1.MutePeoples1.Contains(this)) { Member1.MutePeoples1.Add(this); } if (muteId != Member1.id) { muteId = Member1.id; } } else if (!_settingFK) { muteId = null; } }
private void FixupMember(Member previousValue) { if (previousValue != null && previousValue.Categories.Contains(this)) { previousValue.Categories.Remove(this); } if (Member != null) { if (!Member.Categories.Contains(this)) { Member.Categories.Add(this); } if (requestedById != Member.id) { requestedById = Member.id; } } else if (!_settingFK) { requestedById = null; } }