public BaseResponse UpdateUserName(string newusername, string oldusername, string hashed_password) { BaseResponse baseResponse = new BaseResponse(); try { baseResponse = new MembershipLogic().UpdateUsername(newusername, oldusername, Cryptography.DeHash(hashed_password, true), false); } catch (Exception ex) { EventLogger.LogError("SecureServices.UpdateUsername", string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace)); } return baseResponse; }
public BaseResponse GetMemberByCusId(string hashed_cusid) { bool debug = false; BaseResponse baseResponse = new BaseResponse(); try { baseResponse = new MembershipLogic().GetMemberById(Cryptography.DeHash(hashed_cusid, true), false); } catch (Exception ex) { EventLogger.LogError("MembershipService.GetMemberByCusId", string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace)); } return baseResponse; }
public bool UpdatePassword(string nu, string np) { MembershipLogic target = new MembershipLogic(); BaseResponse actual = target.UpdatePassword(nu, np, debug); return actual != null && actual.TypedResponse != null && actual.TypedResponse.Success; }
//public bool Login(string user, string pwd) //{ // MembershipLogic target = new MembershipLogic(); // BaseResponse actual = target.Login(user, pwd, "", ""); // return actual != null && actual.TypedResponse != null && actual.TypedResponse.Success; //} public bool UpdateUsername(string nu, string iu, string ip) { MembershipLogic target = new MembershipLogic(); BaseResponse actual = target.UpdateUsername(nu, iu, ip, debug); return actual != null && actual.TypedResponse != null && actual.TypedResponse.Success; }
public BaseResponse GetMemberByUsername(string user) { MembershipLogic target = new MembershipLogic(); BaseResponse actual = target.GetMemberByUserName(user); return actual; }
public BaseResponse GetMemberByMemberId(string mbrid) { MembershipLogic target = new MembershipLogic(); return target.GetMemberById(mbrid, true); //return actual != null && actual.TypedResponse != null && actual.TypedResponse.Success; }
public BaseResponse RedeemReferralSubscription(int referralid, string firstname, string lastname, string emailaddress, string countrycode, string address1, string address2, string city, string region, string postal, bool optin, string username, string password) { List<Message> errors = new List<Message>(); string errortext = string.Empty; try { HarperLINQ.Referral referral; #region input validation using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { referral = context.Referrals.SingleOrDefault(r => r.id == referralid); } if (referral == null) { errortext = string.Format(BusinessLogicStrings.invalidReferralIdError, referralid); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } else if (referral.dateredeemed != null || referral.friendid > 0) { errortext = string.Format(BusinessLogicStrings.RedeemedReferralError, referralid); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } else if (referral.dateexpires <= DateTime.Now) { errortext = string.Format(BusinessLogicStrings.expiredReferralError, referralid); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } #endregion else { #region sub order insert Member giftData = new Member(); giftData.FirstName = firstname; giftData.LastName = lastname; giftData.OptIn = optin; giftData.Email = emailaddress; giftData.Address = new Address(); giftData.Address.Address1 = address1; giftData.Address.Address2 = address2; giftData.Address.City = city; giftData.Address.State = region; giftData.Address.PostalCode = postal; giftData.Address.Country = countrycode; SubscriptionServiceRequest request = new SubscriptionServiceRequest(referral, giftData); baseResponse = SubOrderInsert.RedeemReferralSubscription(request); foreach (Message err in baseResponse.Messages) { errors.Add(err); } #endregion MembershipLogic memberlogic = new MembershipLogic(); BaseResponse memberResponse = null; if (errors.Count <= 0) { memberResponse = memberlogic.GetMemberByUserName(emailaddress); } if (!(errors.Count > 0 || memberResponse == null || memberResponse.TypedResponse == null || memberResponse.TypedResponse.Success == false)) { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { GetMemberResponse getMemberResponse = memberResponse.TypedResponse as GetMemberResponse; if (getMemberResponse.MemberFound && getMemberResponse.MemberData != null) { string newMemberId = getMemberResponse.MemberData.MemberId; #region create the user at AH object[] create_response = tbl_Customer.CreateCustomer(address1, address2, "", city, region, countrycode, postal, "Z1", password, "PERSONAL", "", firstname, "", lastname, "", emailaddress, username, newMemberId, referral.pubcode, DateTime.Now.AddMonths(referral.subscriptionlength).ToShortDateString(), DateTime.Now.ToShortDateString(), username, ""); tbl_Customer customer = (tbl_Customer)create_response[1]; #endregion #region referral data at AH referral = context.Referrals.SingleOrDefault(r => r.id == referralid); referral.dateredeemed = DateTime.Now; referral.friendid = customer.cusID; context.SubmitChanges(); #endregion #region send email Mailer mailer = new Mailer(); mailer.SendEmail( ConfigurationManager.AppSettings["mailserviceuser"], ConfigurationManager.AppSettings["mailservicepwd"], "Welcome to the Andrew Harper Community!", ConfigurationManager.AppSettings["referemailfrom"], referral.friendemail, string.Empty, string.Empty, referral.GetReferralUserCreatedEmailBody(), true, ConfigurationManager.AppSettings["smtpserver"]); #endregion } } } else { errortext = string.Format(BusinessLogicStrings.RetrieveMemeberError, new object[] { referralid, emailaddress }); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } } baseResponse.TypedResponse = new AHResponse(); if (errors.Count == 0) { baseResponse.TypedResponse.Success = true; } else { baseResponse.TypedResponse.Success = false; } } catch (Exception ex) { baseResponse.TypedResponse.Success = false; errortext = string.Format(BusinessLogicStrings.UnknownReferralError, ex.Message); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } foreach (Message error in errors) { if (baseResponse == null) { baseResponse = new BaseResponse(); } baseResponse.Messages.Add(error); StringBuilder error_text = new StringBuilder(); error_text.AppendLine("REFERRAL ERROR LOGGED"); error_text.AppendLine(string.Format("REFERRALID {0}", referralid)); baseResponse.Messages.Add(error); error_text.AppendLine(string.Format("ERROR: ", new object[] { })); EventLogger.LogError("SubscriptionLogic.RedeemReferralSubscription", error_text.ToString(), true); } return baseResponse; }
public void GetReferredMembers() { List<string> referred = new List<string>(); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); referred.Add("*****@*****.**"); MembershipLogic target = new MembershipLogic(); List<string> found = new List<string>(); int notfound = 0; foreach(string referral in referred) { BaseResponse actual = target.GetMemberByUserName(referral); if (actual != null && actual.TypedResponse != null && actual.TypedResponse.Success) { try { GetMemberResponse res = actual.TypedResponse as GetMemberResponse; if (res.MemberFound) { if (res.MemberData != null && res.MemberData.Subscriptions != null && res.MemberData.Subscriptions.Count > 0) { System.Diagnostics.Debug.WriteLine(string.Format("SFG ID {0} Subscription count: {1}", res.MemberData.MemberId, res.MemberData.Subscriptions.Count)); found.Add(string.Format("{0}, {1}, {2}", referral, res.MemberData.MemberId, res.MemberData.Subscriptions.Count)); } else { notfound++; } } else { found.Add(string.Format("{0}, {1}, {2}", referral, string.Empty, null)); notfound++; } } catch { notfound++; } } else { notfound++; } System.Diagnostics.Debug.WriteLine(string.Format("Found: {0}", found.Count)); System.Diagnostics.Debug.WriteLine(string.Format("NOT Found: {0}", notfound)); } }
public BaseResponse GetMemberByUserName(string username) { BaseResponse baseResponse = new BaseResponse(); try { baseResponse = new MembershipLogic().GetMemberByUserName(username); } catch (Exception ex) { EventLogger.LogError("MembershipService.GetMemberByUserName", string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace)); } return baseResponse; }
public BaseResponse CreateReferral(string enccusid, string membername, string memeberemail, string keycode, string pubcode, string friendname, string emailaddress, bool ccmember) { BaseResponse baseResponse = new BaseResponse(); try { string cusid = Cryptography.DecryptData(enccusid); baseResponse = new MembershipLogic().CreateReferral(cusid, membername, memeberemail, keycode, pubcode, friendname, emailaddress, ccmember); } catch (Exception ex) { EventLogger.LogError("MembershipService.CreateReferral", string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace)); } return baseResponse; }
public BaseResponse UpdateMember(string hashed_memberid, string salutation, string firstname, string lastname, string suffix, string professionaltitle, string email, bool optin, string businessname, string address1, string address2, string address3, string city, string state, string postalcode, string country, string phone, string screenname) { BaseResponse baseResponse = new BaseResponse(); try { baseResponse = new MembershipLogic().UpdateMember(Cryptography.DeHash(hashed_memberid, true), salutation, firstname, lastname, suffix, professionaltitle, email, optin, businessname, address1, address2, address3, city, state, postalcode, country, phone, screenname, false); } catch (Exception ex) { EventLogger.LogError("MembershipService.UpdateMember", string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace)); } return baseResponse; }
public void GetSubscriptionOffers() { BaseResponse actual = new MembershipLogic().GetSubscriptionOffers(suboffermemberid, debug); if (actual != null && actual.TypedResponse != null && actual.TypedResponse.Success) { Assert.AreEqual((actual.TypedResponse as GetMemberResponse).RenewalOffers == null, false); } else { Assert.AreEqual(1, 0); }; }
public void GetMemberProfile() { BaseResponse actual = new MembershipLogic().GetMemberProfile(memberid, debug); if (actual != null && actual.TypedResponse != null && actual.TypedResponse.Success) { Assert.AreEqual((actual.TypedResponse as GetMemberResponse).MemberData.FirstName == originalfirstname, true); } else { Assert.AreEqual(1, 0); }; }
public void SaveMemberProfile() { BaseResponse original = new MembershipLogic().GetMemberByMemberId(memberid); BaseResponse actual = new MembershipLogic().UpdateMemberProfile(memberid, updatedsalutation, updatedfirstname, updatedmiddleinitial, updatedlastname, updatedsuffix, updatedprofessionaltitle, updatedemail, updatedoptin, updatedbusinessname, updatedaddress1, updatedaddress2, updatedaddress3, updatedcity, updatedstate, updatedpostalcode, updatedcountry, updatedphone, updatedfax, updatedaltcity, debug); BaseResponse updated = new MembershipLogic().GetMemberByMemberId(memberid); coreTests.MyTestCleanup(); if (actual != null && actual.TypedResponse != null && actual.TypedResponse.Success) { Assert.AreEqual((actual.TypedResponse as UpdateMemberResponse).MemberUpdated, true); Assert.AreEqual((original.TypedResponse as GetMemberResponse).MemberData.FirstName == (updated.TypedResponse as GetMemberResponse).MemberData.FirstName, false); } else { Assert.AreEqual(1, 0); }; }
public BaseResponse RedeemReferralSubscription(int referralid, string firstname, string lastname, string emailaddress, string countrycode, string address1, string address2, string city, string region, string postal, bool optin, string username, string password) { List <Message> errors = new List <Message>(); string errortext = string.Empty; try { HarperLINQ.Referral referral; #region input validation using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { referral = context.Referrals.SingleOrDefault(r => r.id == referralid); } if (referral == null) { errortext = string.Format(BusinessLogicStrings.invalidReferralIdError, referralid); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } else if (referral.dateredeemed != null || referral.friendid > 0) { errortext = string.Format(BusinessLogicStrings.RedeemedReferralError, referralid); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } else if (referral.dateexpires <= DateTime.Now) { errortext = string.Format(BusinessLogicStrings.expiredReferralError, referralid); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } #endregion else { #region sub order insert Member giftData = new Member(); giftData.FirstName = firstname; giftData.LastName = lastname; giftData.OptIn = optin; giftData.Email = emailaddress; giftData.Address = new Address(); giftData.Address.Address1 = address1; giftData.Address.Address2 = address2; giftData.Address.City = city; giftData.Address.State = region; giftData.Address.PostalCode = postal; giftData.Address.Country = countrycode; SubscriptionServiceRequest request = new SubscriptionServiceRequest(referral, giftData); baseResponse = SubOrderInsert.RedeemReferralSubscription(request); foreach (Message err in baseResponse.Messages) { errors.Add(err); } #endregion MembershipLogic memberlogic = new MembershipLogic(); BaseResponse memberResponse = null; if (errors.Count <= 0) { memberResponse = memberlogic.GetMemberByUserName(emailaddress); } if (!(errors.Count > 0 || memberResponse == null || memberResponse.TypedResponse == null || memberResponse.TypedResponse.Success == false)) { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { GetMemberResponse getMemberResponse = memberResponse.TypedResponse as GetMemberResponse; if (getMemberResponse.MemberFound && getMemberResponse.MemberData != null) { string newMemberId = getMemberResponse.MemberData.MemberId; #region create the user at AH object[] create_response = tbl_Customer.CreateCustomer(address1, address2, "", city, region, countrycode, postal, "Z1", password, "PERSONAL", "", firstname, "", lastname, "", emailaddress, username, newMemberId, referral.pubcode, DateTime.Now.AddMonths(referral.subscriptionlength).ToShortDateString(), DateTime.Now.ToShortDateString(), username, ""); tbl_Customer customer = (tbl_Customer)create_response[1]; #endregion #region referral data at AH referral = context.Referrals.SingleOrDefault(r => r.id == referralid); referral.dateredeemed = DateTime.Now; referral.friendid = customer.cusID; context.SubmitChanges(); #endregion #region send email Mailer mailer = new Mailer(); mailer.SendEmail( ConfigurationManager.AppSettings["mailserviceuser"], ConfigurationManager.AppSettings["mailservicepwd"], "Welcome to the Andrew Harper Community!", ConfigurationManager.AppSettings["referemailfrom"], referral.friendemail, string.Empty, string.Empty, referral.GetReferralUserCreatedEmailBody(), true, ConfigurationManager.AppSettings["smtpserver"]); #endregion } } } else { errortext = string.Format(BusinessLogicStrings.RetrieveMemeberError, new object[] { referralid, emailaddress }); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } } baseResponse.TypedResponse = new AHResponse(); if (errors.Count == 0) { baseResponse.TypedResponse.Success = true; } else { baseResponse.TypedResponse.Success = false; } } catch (Exception ex) { baseResponse.TypedResponse.Success = false; errortext = string.Format(BusinessLogicStrings.UnknownReferralError, ex.Message); errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null)); } foreach (Message error in errors) { if (baseResponse == null) { baseResponse = new BaseResponse(); } baseResponse.Messages.Add(error); StringBuilder error_text = new StringBuilder(); error_text.AppendLine("REFERRAL ERROR LOGGED"); error_text.AppendLine(string.Format("REFERRALID {0}", referralid)); baseResponse.Messages.Add(error); error_text.AppendLine(string.Format("ERROR: ", new object[] { })); EventLogger.LogError("SubscriptionLogic.RedeemReferralSubscription", error_text.ToString(), true); } return(baseResponse); }