public void Update(object o, System.EventArgs e) { MusicTypeSet mtsFav = Usr.Current.MusicTypesFavourite; Query q = new Query(); q.OrderBy = MusicType.OrderBy; MusicTypeSet mts = new MusicTypeSet(q); List<int> alSel = MusicTypes.SelectedMusicTypes; foreach (MusicType mt in mts) { bool found = false; foreach (MusicType mtFav in mtsFav) { if (mtFav.K == mt.K) { found = true; if (!alSel.Contains(mt.K)) { UsrMusicTypeFavourite u = new UsrMusicTypeFavourite(Usr.Current.K, mt.K); u.Delete(); u.Update(); } break; } } if (!found && alSel.Contains(mt.K)) { UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite(); newMtf.UsrK = Usr.Current.K; newMtf.MusicTypeK = mt.K; newMtf.Update(); } } Usr.Current.MusicTypesFavourite = null; MusicTypes.InitialMusicTypes = Usr.Current.MusicTypesFavourite; MusicTypes.SetState(); UpdatedLabel.Visible = true; Usr.Current.UpdateMusicTypesFavouriteCount(true); if (ContainerPage.Url["NextPage"].Equals("UpdateOptions")) Response.Redirect("/pages/updateoptions"); }
static void updateFromDetailsData(Usr u, Hashtable detailsPanelData) { Place p = new Place((int)detailsPanelData["PlaceK"]); u.HomePlaceK = p.K; u.AddressCountryK = p.CountryK; MusicType mt = new MusicType((int)detailsPanelData["MusicTypeK"]); u.FavouriteMusicTypeK = mt.K; #region update UsrMusicTypeFavourite table try { UsrMusicTypeFavourite umf = new UsrMusicTypeFavourite(); umf.UsrK = u.K; umf.MusicTypeK = mt.K; umf.Update(); u.UpdateMusicTypesFavouriteCount(false); } catch { } #endregion #region update UsrPlaceVisit table try { UsrPlaceVisit upv = new UsrPlaceVisit(); upv.UsrK = u.K; upv.PlaceK = p.K; upv.Update(); u.UpdatePlacesVisitCount(false); } catch { } #endregion #region Facebook u.FacebookStory = (bool)detailsPanelData["Facebook"]; u.FacebookStory1 = (bool)detailsPanelData["Facebook"]; u.FacebookEventAdd = (bool)detailsPanelData["Facebook"]; u.FacebookEventAttend = (bool)detailsPanelData["Facebook"]; u.FacebookStoryAttendEvent = (bool)detailsPanelData["Facebook"]; u.FacebookStoryBuyTicket = (bool)detailsPanelData["Facebook"]; u.FacebookStoryEventReview = (bool)detailsPanelData["Facebook"]; u.FacebookStoryFavourite = (bool)detailsPanelData["Facebook"]; u.FacebookStoryJoinGroup = (bool)detailsPanelData["Facebook"]; u.FacebookStoryLaugh = (bool)detailsPanelData["Facebook"]; u.FacebookStoryNewBuddy = (bool)detailsPanelData["Facebook"]; u.FacebookStoryNewTopic = (bool)detailsPanelData["Facebook"]; u.FacebookStoryPhotoFeatured = (bool)detailsPanelData["Facebook"]; u.FacebookStoryPostNews = (bool)detailsPanelData["Facebook"]; u.FacebookStoryPublishArticle = (bool)detailsPanelData["Facebook"]; u.FacebookStorySpotted = (bool)detailsPanelData["Facebook"]; u.FacebookStoryUploadPhoto = (bool)detailsPanelData["Facebook"]; #endregion #region WeeklyEmail u.SendSpottedEmails = (bool)detailsPanelData["WeeklyEmail"]; #endregion #region PartyInvites u.SendSpottedTexts = (bool)detailsPanelData["PartyInvites"]; u.SendFlyers = (bool)detailsPanelData["PartyInvites"]; u.SendInvites = (bool)detailsPanelData["PartyInvites"]; #endregion u.AgreeTerms = true; u.LegalTermsUser2 = true; u.IsSkeleton = false; u.Update(); #region update Prefs if (mt.K != 1) Prefs.Current["MusicPref"] = mt.K; if (p.CountryK != 224) Prefs.Current["HomeCountryK"] = p.CountryK; if (mt.K != 1 || p.CountryK != 224) Prefs.Current.Update(); #endregion }
private void CreateUsr(int musicTypeK, int homePlaceK, int eventPlaceK, int visitPlaceK, bool isPromoter) { Usr u = new Usr() { Email = Guid.NewGuid().ToString(), IsSkeleton = false, IsEmailVerified = true, SendFlyers = true, HomePlaceK = homePlaceK, IsPromoter = isPromoter }; u.Update(); UsrMusicTypeFavourite um = new UsrMusicTypeFavourite() { UsrK = u.K, MusicTypeK = musicTypeK }; um.Update(); Venue v = new Venue() { PlaceK = eventPlaceK }; v.Update(); Event e = new Event() { VenueK = v.K }; e.Update(); UsrEventAttended ue = new UsrEventAttended() { UsrK = u.K, EventK = e.K }; ue.Update(); UsrPlaceVisit up = new UsrPlaceVisit() { UsrK = u.K, PlaceK = visitPlaceK }; up.Update(); }
public void CountUsrs_MusicConditions_QueryIncludingAllMusic_GetsAllUsrs() { new Delete(TablesEnum.Usr, new Q(true)).Run(); Random r = new Random(); List<int> musicTypeKs = new List<int>() { 1, 2, 3, 4 }; int usrsToCreate = 15; usrsToCreate.Times(() => { Usr u = new Usr() { Email = Guid.NewGuid().ToString(), IsSkeleton = false, IsEmailVerified = true, SendFlyers = true }; u.Update(); int i = r.Next(musicTypeKs.Count * 2); if (i < musicTypeKs.Count) { UsrMusicTypeFavourite um = new UsrMusicTypeFavourite() { UsrK = u.K, MusicTypeK = musicTypeKs[i] }; um.Update(); } }); Assert.AreEqual(usrsToCreate, Flyer.CountUsrs(new List<int>(), musicTypeKs, false)); }
public void CountUsrs_MusicConditions_TestChildImpliesParentMusicType() { new Delete(TablesEnum.Usr, new Q(true)).Run(); // 4 is parent of 5 List<int> musicTypeKs = new List<int>() { 5 }; Usr u = new Usr() { Email = Guid.NewGuid().ToString(), IsSkeleton = false, IsEmailVerified = true, SendFlyers = true }; u.Update(); UsrMusicTypeFavourite um = new UsrMusicTypeFavourite() { UsrK = u.K, MusicTypeK = 4 }; um.Update(); Assert.AreEqual(1, Flyer.CountUsrs(new List<int>(), musicTypeKs, false)); }
public void PrefsUpdateClick(object o, System.EventArgs e) { Page.Validate(); bool sendVerifyEmail = false; if (Page.IsValid) { #region Handle change of email address if (Usr.Current.Email != Email.Text) { //Check for duplicate email addresses in the database Query q = new Query(); q.QueryCondition = new Q(Usr.Columns.Email, Email.Text); q.ReturnCountOnly = true; UsrSet ds = new UsrSet(q); if (ds.Count == 0) { //No duplicate - update email address Usr.Current.AdminNote += "\nThis user changed their email address from " + Usr.Current.Email + " to " + Email.Text + " on " + DateTime.Now.ToString(); Usr.Current.Email = Email.Text; Usr.Current.EmailDateTime = DateTime.Now; if (HttpContext.Current != null) Usr.Current.EmailIp = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]); Usr.Current.IsEmailVerified = false; Usr.Current.IsEmailBroken = false; sendVerifyEmail = true; } else { //Duplicate - display error EmailDuplicateValidator.IsValid = false; } } #endregion #region Handle phone number entry System.Text.RegularExpressions.Regex rNumbers = new System.Text.RegularExpressions.Regex("[^0123456789]"); string mobileNumber = rNumbers.Replace(MobileNumber.Text.Trim(), ""); string dialingCode = rNumbers.Replace(DialingCodeDropDown.SelectedValue, ""); string dialingCodeOther = rNumbers.Replace(DialingCodeOther.Text.Trim(), ""); string fullMobile = ""; if (mobileNumber.StartsWith("0")) { mobileNumber = mobileNumber.Substring(1); } if (dialingCode.Equals("0")) { dialingCode = dialingCodeOther; } if (mobileNumber.Length > 0) { fullMobile = dialingCode + mobileNumber; } if (MobileNumber.Text != mobileNumber) MobileNumber.Text = mobileNumber; if (DialingCodeDropDown.SelectedValue.Equals("0") && DialingCodeOther.Text != dialingCode) DialingCodeOther.Text = dialingCode; #endregion //Database will only update if all validators are valid if (Page.IsValid) { Usr.Current.FirstName = Cambro.Web.Helpers.StripHtml(FirstName.Text).Trim(); Usr.Current.LastName = Cambro.Web.Helpers.StripHtml(LastName.Text).Trim(); string nick = Usr.GetCompliantNickName(NickName.Text); Usr.Current.NickName = nick; Usr.Current.IsSkeleton = false; if (!Usr.Current.Mobile.Equals(fullMobile)) Usr.Current.AdminNote += "\n\nUsr has changed mobile number from " + Usr.Current.Mobile + " to: " + fullMobile + " on " + DateTime.Now.ToString() + ".\n"; Usr.Current.Mobile = fullMobile; Usr.Current.MobileCountryCode = dialingCode; Usr.Current.MobileNumber = mobileNumber; Usr.Current.IsMale = SexMale.Checked; Usr.Current.IsFemale = SexFemale.Checked; Usr.Current.DateOfBirth = new DateTime(int.Parse(DateOfBirthYear.Text), int.Parse(DateOfBirthMonth.Text), int.Parse(DateOfBirthDay.Text)); Usr.Current.SendSpottedEmails = SendSpottedEmails.Checked; Usr.Current.SendSpottedTexts = SendSpottedTexts.Checked; Usr.Current.SendFlyers = SendFlyers.Checked; Usr.Current.SendInvites = SendInvites.Checked; Usr.Current.LegalTermsUser2 = true; Usr.Current.IsDj = IsDjYes.Checked; #region Update hometown and add UsrPlaceVisit record for this place Place p = new Place(int.Parse(HomeTownDropDownList.SelectedValue)); if (Usr.Current.HomePlaceK != p.K) { Usr.Current.HomePlaceK = p.K; try { UsrPlaceVisit upv = new UsrPlaceVisit(Usr.Current.K, p.K); } catch { UsrPlaceVisit upv = new UsrPlaceVisit(); upv.UsrK = Usr.Current.K; upv.PlaceK = p.K; upv.Update(); } } Usr.Current.UpdatePlacesVisitCount(false); #endregion #region Update favourite music and add UsrMusicTypeFavourite record for this musictype MusicType mt = new MusicType(int.Parse(FavouriteMusicDropDownList.SelectedValue)); if (Usr.Current.FavouriteMusicTypeK != mt.K) { Usr.Current.FavouriteMusicTypeK = mt.K; Prefs.Current["MusicPref"] = mt.K; try { UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite(Usr.Current.K, mt.K); } catch { UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite(); newMtf.UsrK = Usr.Current.K; newMtf.MusicTypeK = mt.K; newMtf.Update(); } } Usr.Current.UpdateMusicTypesFavouriteCount(false); #endregion if (!Usr.Current.IsSkeletonFromSignup && Password2.Text.Length > 0) { //Remove all saved cards... Usr.Current.DeleteAllSavedCards(); Usr.Current.SetPassword(Password2.Text.Trim(), false); } Usr.Current.Update(); if (Usr.Current.GroupsWhoHavePendingInvitationsForMe.Count > 0) { foreach (GridViewRow gvr in uiAddedByGroupsGridView.Rows) { if (((CheckBox)gvr.FindControl("uiCheckBox")).Checked) { int groupK = (int)uiAddedByGroupsGridView.DataKeys[gvr.RowIndex].Value; try { Group g = new Group(groupK); GroupUsr gu = g.GetGroupUsr(Usr.Current); if (Bobs.Group.AllowJoinRequest(Usr.Current, g, gu)) g.Join(Usr.Current, gu); } catch { } } } } if (Usr.Current.UsrsWhoHavePendingBuddyRequestsForMe.Count > 0) { foreach (GridViewRow gvr in uiAddedByUsrsGridView.Rows) { if (((CheckBox)gvr.FindControl("uiCheckBox")).Checked) { int buddyUsrK = (int)uiAddedByUsrsGridView.DataKeys[gvr.RowIndex].Value; try { Usr.Current.AddBuddy(new Usr(buddyUsrK), Usr.AddBuddySource.WelcomePage, Buddy.BuddyFindingMethod.Nickname, null); } catch (Exception ex) { SpottedException.TryToSaveExceptionAndChildExceptions(ex, HttpContext.Current, Usr.Current, Visit.Current, "", "Welcome page", "", 0, null); } } } } #region Send email verify email, if needed if (sendVerifyEmail) { Mailer mail = new Mailer(); mail.SendEvenIfUnverifiedOrBroken = true; mail.Subject = "You changed your DontStayIn email address..."; mail.Body = @"<h1>You changed your email address...</h1><p>Please click the following link to verify your email address and allow posting to our discussion boards:</p> <p align=""center"" style=""padding:8px 0px 9px 0px;""><a href=""[LOGIN]"" style=""font-size:14px;font-weight:bold;"">Click here to verify your email</a></p>"; mail.To = Usr.Current.Email; mail.UsrRecipient = Usr.Current; mail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; mail.Send(); } #endregion Log.Increment(Log.Items.WelcomeSignUp); if (Usr.Current.AddedByGroupK > 0) { if (Request.QueryString["Url"] != null && Request.QueryString["Url"].Length > 0) Response.Redirect(Request.QueryString["Url"]); else Response.Redirect(Usr.Current.AddedByGroup.Url()); } else { if (Request.QueryString["Url"] != null && Request.QueryString["Url"].Length > 0) Response.Redirect("/popup/mixmag?url=" + HttpUtility.UrlEncode(Request.QueryString["Url"])); else Response.Redirect("/popup/mixmag"); } } } }
public void PrefsUpdateClick(object o, System.EventArgs e) { string PreviousUrlFilterPart = ThisUsr.UrlFilterPart; ChangePanel(PrefsUpdatePanel); Page.Validate(); //bool doUpdate = false; bool sendVerifyEmail = false; if (Page.IsValid) { if (ThisUsr.Email != Email.Text) { //Email has changed - check email //Check for duplicates email addresses in the database UsrSet ds = new UsrSet(new Query(new Q(Usr.Columns.Email, Email.Text))); if (ds.Count == 0) { //No duplicate - update email address ThisUsr.AdminNote += "\nThis user changed their email address from " + ThisUsr.Email + " to " + Email.Text + " on " + DateTime.Now.ToString(); ThisUsr.Email = Email.Text; ThisUsr.EmailDateTime = DateTime.Now; if (HttpContext.Current != null) ThisUsr.EmailIp = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]); ThisUsr.IsEmailVerified = false; ThisUsr.IsEmailBroken = false; sendVerifyEmail = true; //doUpdate = true; } else { //Duplicate - display error emailDuplicateValidator.IsValid = false; } } Regex rNumbers = new Regex("[^0123456789]"); string mobileNumber = rNumbers.Replace(MobileNumber.Text.Trim(), ""); string dialingCode = rNumbers.Replace(DialingCodeDropDown.SelectedValue, ""); string dialingCodeOther = rNumbers.Replace(DialingCodeOther.Text.Trim(), ""); string fullMobile = ""; if (mobileNumber.StartsWith("0")) { mobileNumber = mobileNumber.Substring(1); } if (dialingCode.Equals("0")) { dialingCode = dialingCodeOther; } if (mobileNumber.Length > 0) { fullMobile = dialingCode + mobileNumber; } if (MobileNumber.Text != mobileNumber) MobileNumber.Text = mobileNumber; if (DialingCodeDropDown.SelectedValue.Equals("0") && DialingCodeOther.Text != dialingCode) DialingCodeOther.Text = dialingCode; string nick = Usr.GetCompliantNickName(NickName.Text); if (ThisUsr.NickName != nick && nick.ToUpper().Contains("-DSI") && !ThisUsr.IsAdmin) { throw new DsiUserFriendlyException("Invalid user name. Please try another."); } //Database will only update if all validators are valid and doUpdate has been set to true by a change if (Page.IsValid) { ThisUsr.FirstName = Cambro.Web.Helpers.StripHtml(FirstName.Text); ThisUsr.LastName = Cambro.Web.Helpers.StripHtml(LastName.Text); if (NickName.Text.Length > 20) throw new DsiUserFriendlyException("Nickname must be 20 chars or less!"); ThisUsr.NickName = nick; if (!ThisUsr.Mobile.Equals(fullMobile)) ThisUsr.AdminNote += "\n\nUsr has changed mobile number from " + ThisUsr.Mobile + " to: " + fullMobile + " on " + DateTime.Now.ToString() + ".\n"; ThisUsr.Mobile = fullMobile; ThisUsr.MobileCountryCode = dialingCode; ThisUsr.MobileNumber = mobileNumber; ThisUsr.AddressArea = Cambro.Web.Helpers.StripHtml(AddressAreaTextBox.Text); ThisUsr.AddressPostcode = Cambro.Web.Helpers.StripHtml(AddressPostcodeTextBox.Text); ThisUsr.AddressCountryK = Convert.ToInt32(AddressCountryDropDownList.SelectedValue); ThisUsr.AddressCounty = Cambro.Web.Helpers.StripHtml(AddressCountyTextBox.Text); ThisUsr.AddressStreet = Cambro.Web.Helpers.StripHtml(AddressStreetTextBox.Text); ThisUsr.AddressTown = Cambro.Web.Helpers.StripHtml(AddressTownTextBox.Text); ThisUsr.IsMale = SexMale.Checked; ThisUsr.IsFemale = SexFemale.Checked; ThisUsr.IsDj = IsDjYes.Checked; ThisUsr.DateOfBirth = new DateTime(int.Parse(DateOfBirthYear.Text), int.Parse(DateOfBirthMonth.Text), int.Parse(DateOfBirthDay.Text)); //Place p = new Place(int.Parse(HomeTownDropDownList.SelectedValue)); Place p = HomeTownPlacePicker.Place; if (ThisUsr.HomePlaceK != p.K) { ThisUsr.HomePlaceK = p.K; ThisUsr.Home = null; try { UsrPlaceVisit upv = new UsrPlaceVisit(ThisUsr.K, p.K); } catch { UsrPlaceVisit upv = new UsrPlaceVisit(); upv.UsrK = ThisUsr.K; upv.PlaceK = p.K; upv.Update(); } ThisUsr.UpdatePlacesVisitCount(false); } if (ThisUsr.K == Usr.Current.K && !ThisUsr.IsOfLegalDrinkingAgeInHomeCountry) Prefs.Current.Remove("Drink"); bool changeMusicPref = false; MusicType mt = new MusicType(int.Parse(FavouriteMusicDropDownList.SelectedValue)); if (ThisUsr.FavouriteMusicTypeK != mt.K) { changeMusicPref = true; ThisUsr.FavouriteMusicTypeK = mt.K; } if (sendVerifyEmail) { ThisUsr.LoginString = Cambro.Misc.Utility.GenRandomText(6); } ThisUsr.Update(); Usr.Current = null; if (changeMusicPref) { if (ThisUsr.K == Usr.Current.K) Prefs.Current["MusicPref"] = mt.K; try { UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite(ThisUsr.K, mt.K); } catch { UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite(); newMtf.UsrK = ThisUsr.K; newMtf.MusicTypeK = mt.K; newMtf.Update(); } ThisUsr.UpdateMusicTypesFavouriteCount(true); } SuccessDiv.Visible = true; if (sendVerifyEmail) { Mailer mail = new Mailer(); mail.Subject = "You changed your DontStayIn registered email address..."; mail.Body = @"<h1>You changed your email address...</h1><p>Please click the following link to verify your email address and allow posting to our discussion boards:</p> <p align=""center"" style=""padding:8px 0px 9px 0px;""><a href=""[LOGIN]"" style=""font-size:14px;font-weight:bold;"">Click here to verify your email</a></p>"; mail.To = ThisUsr.Email; mail.UsrRecipient = ThisUsr; mail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; mail.SendEvenIfUnverifiedOrBroken = true; mail.Send(); } if (Request.QueryString["Url"] != null && Request.QueryString["Url"].Length > 0) Response.Redirect(Request.QueryString["Url"]); else Response.Redirect(ThisUsr.UrlApp("edit") + "?done=1"); //if (!PreviousUrlFilterPart.Equals(ThisUsr.UrlFilterPart)) //Response.Redirect(ThisUsr.UrlApp("edit")); } } }