/// <summary>
 /// 
 /// </summary>
 /// <param name="profileMemberDetail"></param>
 /// <param name="refreshCustomer"></param>
 /// <param name="optIn"></param>
 /// <param name="debug"></param>
 public UpdateCustomerProfileRequest(Member profileMember, bool refreshCustomer, bool optIn, bool debug)
 {
     base.Debug = debug;
     this.MemberData = profileMember;
     this.RefreshCustomer = refreshCustomer;
     this.OptIn = optIn;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="memberCreditCard"></param>
 /// <param name="transactionType"></param>
 /// <param name="amount"></param>
 /// <param name="debug"></param>
 public ChargeCardRequest(CreditCard creditCardData, Member memberData, float amount, bool debug)
 {
     base.Debug = debug;
     this.CreditCardData = creditCardData;
     this.MemberData = memberData;
     this.Amount = amount;
 }
 public CreditCardServiceRequest(CreditCard creditcarddata, Member memberdata, string pubcode, string username, string password, bool refreshcustomer)
 {
     CreditCardData = creditcarddata;
     MemberData = memberdata;
     ProgramId = pubcode;
     UserName = username;
     Password = password;
     RefreshCustomer = refreshcustomer;
 }
        public BaseResponse UpdateMemberProfile(string memberid,
            string salutation, string firstname, string middleinitial, 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 fax, string altcity,
            bool debug)
        {
            methodName = "UpdateMemberProfile";
            LogMethodEntry(methodName);
            try
            {
                #region  set member data
                Member memberData = new Member();
                memberData.MemberId = memberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.MiddleInitial = middleinitial;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn = optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                memberData.Address.Fax = fax;
                memberData.Address.AltCity = altcity;
                #endregion

                UpdateMemberRequest request = new UpdateMemberRequest(memberData, debug);
                baseResponse = CustomerUpdate.UpdateMember(request);
            }
            catch (InvalidInputException)
            {
                //need to add and handle input validation errors
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            LogMethodExit(methodName);
            return baseResponse;
        }        
        public UpdateMemberRequest(string sfgid, string prefix, string firstname, string lastname, string suffix, string title, string email, bool optin,
                                   string company, string address1, string address2, string address3, string city, string region, string postalcode, string country, string phone)
        {
            MemberToUpdate = new Member();
            MemberToUpdate.MemberId = sfgid;
            MemberToUpdate.Salutation = prefix;
            MemberToUpdate.FirstName = firstname;
            MemberToUpdate.LastName = lastname;
            MemberToUpdate.Suffix = suffix;
            MemberToUpdate.ProfessionalTitle = title;
            MemberToUpdate.OptIn = optin;                          
            MemberToUpdate.Email = email;

            MemberToUpdate.Address = new Address();
            MemberToUpdate.Address.BusinessName = company;
            MemberToUpdate.Address.Address1 = address1;
            MemberToUpdate.Address.Address2 = address2;
            MemberToUpdate.Address.Address3 = address3;
            MemberToUpdate.Address.City = city;
            MemberToUpdate.Address.State = region;
            MemberToUpdate.Address.PostalCode = postalcode;
            MemberToUpdate.Address.Country = country;
            MemberToUpdate.Address.Phone = phone;
        }
        public CreateSubscriptionRequest(Member memberData, Member giftData, string verifoneRoutingId, int subscriptionLength,
            float amountPaid, string keyCode, string pubCode, bool refreshCustomer, bool giftflag, bool debug)
        {
            Debug = debug;
            VerifoneRoutingId = verifoneRoutingId; 
            SubscriptionLength = subscriptionLength;
            Price = amountPaid;
            AmountPaid = amountPaid;
            KeyCode =  keyCode;
            RefreshCustomer = refreshCustomer;
            GiftFlag = giftflag;
            PublicationCode = pubCode;

            #region member data
            SubscribingMember.MemberId = memberData.MemberId;
            SubscribingMember.Salutation = memberData.Salutation;
            SubscribingMember.FirstName = memberData.FirstName;
            SubscribingMember.MiddleInitial = memberData.MiddleInitial;
            SubscribingMember.LastName = memberData.LastName;
            SubscribingMember.Suffix = memberData.Suffix;
            SubscribingMember.ProfessionalTitle = memberData.ProfessionalTitle;
            SubscribingMember.Email = memberData.Email;
            SubscribingMember.OptIn = memberData.OptIn;

            SubscribingMember.Address = new Address();
            SubscribingMember.Address.BusinessName = memberData.Address.BusinessName;
            SubscribingMember.Address.Address1 = memberData.Address.Address1;
            SubscribingMember.Address.Address2 = memberData.Address.Address2;
            SubscribingMember.Address.Address3 = memberData.Address.Address3;
            SubscribingMember.Address.City = memberData.Address.City;
            SubscribingMember.Address.State = memberData.Address.State;
            SubscribingMember.Address.PostalCode = memberData.Address.PostalCode;
            SubscribingMember.Address.Country = memberData.Address.Country;
            SubscribingMember.Address.Phone = memberData.Address.Phone;
            SubscribingMember.Address.AltCity = memberData.Address.AltCity;
            #endregion

            #region gift member data
            GiftRecipient.MemberId = memberData.MemberId;
            GiftRecipient.Salutation = memberData.Salutation;
            GiftRecipient.FirstName = memberData.FirstName;
            GiftRecipient.MiddleInitial = memberData.MiddleInitial;
            GiftRecipient.LastName = memberData.LastName;
            GiftRecipient.Suffix = memberData.Suffix;
            GiftRecipient.ProfessionalTitle = memberData.ProfessionalTitle;
            GiftRecipient.Email = memberData.Email;
            GiftRecipient.OptIn = memberData.OptIn;

            GiftRecipient.Address = new Address();
            GiftRecipient.Address.BusinessName = memberData.Address.BusinessName;
            GiftRecipient.Address.Address1 = memberData.Address.Address1;
            GiftRecipient.Address.Address2 = memberData.Address.Address2;
            GiftRecipient.Address.Address3 = memberData.Address.Address3;
            GiftRecipient.Address.City = memberData.Address.City;
            GiftRecipient.Address.State = memberData.Address.State;
            GiftRecipient.Address.PostalCode = memberData.Address.PostalCode;
            GiftRecipient.Address.Country = memberData.Address.Country;
            GiftRecipient.Address.Phone = memberData.Address.Phone;
            GiftRecipient.Address.AltCity = memberData.Address.AltCity;
            #endregion

        }
Beispiel #7
0
        public void ApproveCC()
        {
            throw new NotImplementedException();
            //CreditCardLogic target = new CreditCardLogic();

            #region set cc data
            CreditCard creditCardData = new CreditCard();
            creditCardData.CCAddress = ccaddress;
            creditCardData.CCCity = cccity;
            creditCardData.CCExpMonth = short.Parse(ccexpmonth);
            creditCardData.CCExpYear = short.Parse(ccexpyear);
            creditCardData.CCName = ccname;
            creditCardData.CCPostalCode = ccpostalcode;
            creditCardData.CCState = ccstate;
            #endregion

            #region set member data
            Member memberData = new Member();
            memberData.Salutation = updatedsalutation;
            memberData.FirstName = updatedfirstname;
            memberData.MiddleInitial = updatedmiddleinitial;
            memberData.LastName = updatedlastname;
            memberData.Suffix = updatedsuffix;
            memberData.ProfessionalTitle = updatedprofessionaltitle;
            memberData.Email = updatedemail;
            memberData.OptIn = updatedoptin;
            memberData.Address.BusinessName = updatedbusinessname;
            memberData.Address.Address1 = updatedaddress1;
            memberData.Address.Address2 = updatedaddress2;
            memberData.Address.Address3 = updatedaddress3;
            memberData.Address.City = updatedcity;
            memberData.Address.State = updatedstate;
            memberData.Address.PostalCode = updatedpostalcode;
            memberData.Address.Country = updatedcountry;
            memberData.Address.Phone = updatedphone;
            memberData.Address.Fax = updatedfax;
            memberData.Address.AltCity = updatedaltcity;
            #endregion

            //creditCardData.CCNumber = goodamex;
            //BaseResponse actual = target.ChargeCard(creditCardData, memberData, amountpaid, debug);
            //Assert.AreEqual(true, actual != null && actual.TypedResponse != null && actual.TypedResponse.Success);
            //verifoneroutingid = ((ChargeCardResponse)actual.TypedResponse).VerifoneRoutingId;

            //creditCardData.CCNumber = gooddisc;
            //actual = target.ChargeCard(creditCardData, memberData, amountpaid, debug);
            //Assert.AreEqual(true, actual != null && actual.TypedResponse != null && actual.TypedResponse.Success);
            //verifoneroutingid = ((ChargeCardResponse)actual.TypedResponse).VerifoneRoutingId;

            //creditCardData.CCNumber = goodmc;
            //actual = target.ChargeCard(creditCardData, memberData, amountpaid, debug);
            //Assert.AreEqual(true, actual != null && actual.TypedResponse != null && actual.TypedResponse.Success);
            //verifoneroutingid = ((ChargeCardResponse)actual.TypedResponse).VerifoneRoutingId;

            //creditCardData.CCNumber = goodvisa;
            //actual = target.ChargeCard(creditCardData, memberData, amountpaid, debug);
            //Assert.AreEqual(true, actual != null && actual.TypedResponse != null && actual.TypedResponse.Success);
            //verifoneroutingid = ((ChargeCardResponse)actual.TypedResponse).VerifoneRoutingId;
        }
        public BaseResponse CreateSubscription(int subscriptionlength, 
            float amountpaid, string verifoneroutingid, 
            string publicationcode, string keycode, 
            string renewingmemberid, string salutation, string firstname, string middleinitial, 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 fax, string altcity, 
            bool giftflag, 
            string renewinggiftmemberid, string giftsalutation, string giftfirstname, string giftmiddleinitial, string giftlastname, string giftsuffix,
            string giftprofessionaltitle, string giftemail, bool giftoptin, string giftbusinessname, string giftaddress1, string giftaddress2, string giftaddress3,
            string giftcity, string giftstate, string giftpostalcode, string giftcountry,
            string giftphone, string giftfax, string giftaltcity)
        {
            try
            {
                #region set member data
                Member memberData = new Member();
                memberData.MemberId = renewingmemberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.MiddleInitial = middleinitial;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn = optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                memberData.Address.Fax = fax;
                memberData.Address.AltCity = altcity;

                Member giftData = new Member();
                //giftData.MemberId = renewinggiftmemberid;
                //giftData.Salutation = salutation;
                //giftData.FirstName = firstname;
                //giftData.MiddleInitial = middleinitial;
                //giftData.LastName = lastname;
                //giftData.Suffix = suffix;
                //giftData.ProfessionalTitle = professionaltitle;
                //giftData.OptIn = optin;
                //giftData.Email = email;

                //giftData.Address = new Address();
                //giftData.Address.BusinessName = businessname;
                //giftData.Address.Address1 = address1;
                //giftData.Address.Address2 = address2;
                //giftData.Address.Address3 = address3;
                //giftData.Address.City = city;
                //giftData.Address.State = state;
                //giftData.Address.PostalCode = postalcode;
                //giftData.Address.Country = country;
                //giftData.Address.Phone = phone;
                //giftData.Address.Fax = fax;
                //giftData.Address.AltCity = altcity;
                #endregion

                #region set cc data
                CreditCard creditCardData = new CreditCard();
                creditCardData.Price = amountpaid;
                creditCardData.AmountPaid = amountpaid;
                creditCardData.VerifoneRoutingId = verifoneroutingid;
                #endregion

                SubscriptionServiceRequest request = new SubscriptionServiceRequest(memberData, giftData, creditCardData, 
                        publicationcode, keycode, giftflag, subscriptionlength);
                baseResponse = SubOrderInsert.CreateSubscription(request);       
            }
            catch (Exception ex)
            {
                EventLogger.LogError("SubscriptionLogic.CreateSubscription", ex.Message);
            }
            return baseResponse;
        }
        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;
        }        
Beispiel #10
0
 public static Subscription GetCompSubscription(Member member)
 {
     Subscription compsubscription = new Subscription();
     compsubscription.Category = SubscriptionCategory.Publication;
     compsubscription.SubscribingMember = member.MemberId;
     compsubscription.StatusFlag = "p";
     string sql = "svcs_GetCompMember";
     using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     using (SqlCommand comm = new SqlCommand(sql, conn))
     {
         conn.Open();
         comm.CommandType = System.Data.CommandType.StoredProcedure;
         comm.Parameters.Add(new SqlParameter("@cusid", member.CusId));
         SqlDataReader reader = comm.ExecuteReader();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 compsubscription.PublicationCode = Utilities.GetStringFromDB(reader["mtycode"]);
                 compsubscription.DateEntered = Utilities.GetStringFromDB(reader["nmbdatestart"]);
                 compsubscription.ExpireDate = Utilities.GetStringFromDB(reader["nmbdateend"]);
             }
         }
         reader.Close();
     }            
     return compsubscription;
 }
Beispiel #11
0
 /// <summary>
 /// Gets cusid and screen name for comp member
 /// </summary>
 /// <param name="username"></param>
 /// <returns></returns>
 public static Member GetCompMember(string username)
 {
     Member compmember = new Member();
     compmember.UserName = username;
     string sql = "svcs_GetCompMember";
     using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     using (SqlCommand comm = new SqlCommand(sql, conn))
     {
         conn.Open();
         comm.CommandType = System.Data.CommandType.StoredProcedure;
         comm.Parameters.Add(new SqlParameter("@username", username));
         SqlDataReader reader = comm.ExecuteReader();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 if (reader["cusid"].ToString().GetType().Name == "DBNull")
                 {
                     reader.Close();
                     throw new Exception("No cusid for member");
                 }
                 compmember.CusId = Utilities.GetStringFromDB(reader["cusid"]);
                 compmember.FirstName = Utilities.GetStringFromDB(reader["cusfirstname"]);
                 compmember.LastName = Utilities.GetStringFromDB(reader["cuslastname"]);
                 compmember.Email = Utilities.GetStringFromDB(reader["cusemail"]);
                 compmember.Salutation = Utilities.GetStringFromDB(reader["cusprefix"]);
                 compmember.ProfessionalTitle = Utilities.GetStringFromDB(reader["custitle"]);
                 compmember.ScreenName = Utilities.GetStringFromDB(reader["cusdisplayname"]);
                 compmember.Suffix = Utilities.GetStringFromDB(reader["cussuffix"]);
                 compmember.Address.Address1 = Utilities.GetStringFromDB(reader["addaddress1"]);
                 compmember.Address.Address2 = Utilities.GetStringFromDB(reader["addaddress2"]);
                 compmember.Address.Address3 = Utilities.GetStringFromDB(reader["addaddress3"]);
                 compmember.Address.BusinessName = Utilities.GetStringFromDB(reader["cuscompany"]);
                 compmember.Address.City = Utilities.GetStringFromDB(reader["addcity"]);
                 compmember.Address.Country = Utilities.GetStringFromDB(reader["addcountry"]);
                 compmember.Address.Fax = Utilities.GetStringFromDB(reader["cusfax"]);
                 compmember.Address.Phone = Utilities.GetStringFromDB(reader["cusphone1"]);
                 compmember.Address.PostalCode = Utilities.GetStringFromDB(reader["addpostalcode"]);
                 compmember.Address.State = Utilities.GetStringFromDB(reader["addregion"]);
             }
         }
         reader.Close();
     }
     return compmember; 
 }
Beispiel #12
0
        /// <summary>
        /// Creates member at AH from data returned by SFG, returns true if member already exists
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        public static bool CreateMember(Member member) 
        {
            using (SupportDataDataContext context = new SupportDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
            {
                var customer = (from a in context.Customers where a.cusUserName == member.UserName select a).SingleOrDefault();
                var sfglink = (from a in context.SFG_CustomerNumbers where a.SFGCustNum == member.MemberId select a).SingleOrDefault();

                if (customer == null && sfglink != null)
                {
                    //someone else already has that sfgid
                    return false;
                }
                try
                {
                    if (customer == null)
                    {
                        AddressCustomer address = new AddressCustomer();
                        address.addAddress1 = member.Address.Address1;
                        address.addAddress2 = member.Address.Address2;
                        address.addAddress3 = member.Address.Address3;
                        address.addCity = member.Address.City;
                        address.addCountry = member.Address.Country;
                        address.addDateCreated = DateTime.Now;
                        address.addDateUpdated = DateTime.Now;
                        address.addPostalCode = member.Address.PostalCode;
                        address.addRegion = member.Address.State;
                        context.AddressCustomers.InsertOnSubmit(address);
                        context.SubmitChanges();

                        var custnum = (from a in context.Customers select a.cusCustNum).Max();
                        int nextcustnum = int.Parse(custnum) + 1;

                        customer = new Customer();
                        customer.addID = address.addID;
                        customer.cusCustNum = nextcustnum.ToString();
                        customer.cusFirstName = member.FirstName;
                        customer.cusLastName = member.LastName;
                        customer.cusCustType = "UNKNOWN";
                        customer.cusPriFirstName = member.FirstName;
                        customer.cusPriLastName = member.LastName;
                        customer.cusPrefix = member.Salutation;
                        customer.cusSuffix = member.Suffix;
                        customer.cusEmail = member.Email;
                        customer.cusUserName = member.UserName;
                        customer.cusIsCharterMem = false;
                        customer.cusIsDeleted = false;
                        customer.cusSex = 'U';
                        customer.cusHasDisplayName = true;
                        customer.cusDisplayName = member.UserName;
                        customer.cusGUID = Guid.NewGuid();
                        context.Customers.InsertOnSubmit(customer);
                        context.SubmitChanges();
                    }
                    if (sfglink == null)
                    {
                        sfglink = new SFG_CustomerNumber();
                        sfglink.SFGCustNum = member.MemberId;
                        sfglink.cusID = customer.cusID;
                        context.SFG_CustomerNumbers.InsertOnSubmit(sfglink);
                        context.SubmitChanges();
                    }
                }
                catch
                {
                    return false;
                }
            }
            return true;
        }
Beispiel #13
0
 /// <summary>
 /// The cusids and usernames must match if this sfgid exists at AH.
 /// If screenname isn't empty then it must also match
 /// If no cusid passed in, checks to see that username is available.
 /// </summary>
 /// <param name="username"></param>
 /// <param name="cusid"></param>
 /// <param name="screenname"></param>
 /// <param name="memberid"></param>
 /// <returns></returns>
 public static bool CheckSFGHarperSync(string username, string cusid, string screenname, string memberid)
 {
     bool isSynced = false;
     Member mbr = new Member();
     if (string.IsNullOrEmpty(cusid))
     {
         string sql = string.Format("select cusid from tbl_customer where cususername = '******' or cusdisplayname = {1}", new object[]{username,screenname});
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
         using (SqlCommand comm = new SqlCommand(sql, conn))
         {
             conn.Open();
             SqlDataReader reader = comm.ExecuteReader();
             if (reader.HasRows)
             {
                 isSynced = false;                                  //username and screenname is not available so this account cannot be created
             }
             else
             {
                 isSynced = true;                                   //username and screenname is available so this account can be created
             }
             reader.Close();
         }
     }
     else
     {
         mbr.UserName = username;
         string sql = string.Format("select a.cusid, b.cususername, b.cusdisplayname from sfg_customernumbers a join tbl_customer b on a.cusid = b.cusid where a.sfgcustnum = '{0}'", memberid);
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
         using (SqlCommand comm = new SqlCommand(sql, conn))
         {
             conn.Open();
             SqlDataReader reader = comm.ExecuteReader();
             if (reader.HasRows)
             {
                 while (reader.Read())
                 {
                     if (reader["cusid"].GetType().Name != "DBNull")
                     {
                         mbr.CusId = reader["cusid"].ToString();
                     }
                     if (reader["cususername"].GetType().Name != "DBNull")
                     {
                         mbr.UserName = reader["cususername"].ToString();
                     }
                     if (reader["cusdisplayname"].GetType().Name != "DBNull")
                     {
                         mbr.ScreenName = reader["cusdisplayname"].ToString();
                     }
                     isSynced = mbr.CusId == cusid                       //the cusid must match the input 
                         && mbr.UserName == username;                    //the username must match the input
                     if (isSynced && !string.IsNullOrEmpty(screenname))
                     {
                         isSynced = mbr.ScreenName == screenname;        //if screenname passed in it must match
                     }
                 }
             }
             else
             {
                 isSynced = false;                                   //no data at AH so nothing to sync                                   
             }
             reader.Close();
         }
     }
     return isSynced;
 }
Beispiel #14
0
 /// <summary>
 /// get cusid, cusdisplayname from tbl_customer by cususername 
 /// if this username exists at AH:
 /// 1 - the cusids must match and 2 - screenname (if one was sent) must match
 /// </summary>
 /// <param name="username"></param>
 /// <param name="cusid"></param>
 /// <param name="screenname"></param>
 /// <returns></returns>
 public static bool CheckDrupalHarperSync(string username, string cusid, string screenname)
 {
     bool isSynced = true;
     Member mbr = new Member();
     if (string.IsNullOrEmpty(username))
     {
         throw new Exception("Empty username sent to CheckDrupalHarperSync");
     }
     else
     {
         mbr.UserName = username;
         string sql = string.Format("select cusid, cusdisplayname from tbl_customer where cususername = '******'", mbr.UserName);
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
         using (SqlCommand comm = new SqlCommand(sql, conn))
         {
             conn.Open();
             SqlDataReader reader = comm.ExecuteReader();
             if (reader.HasRows)                                     //do we have this username at AH?
             {
                 while (reader.Read())
                 {
                     if (reader["cusid"].GetType().Name != "DBNull")
                     {
                         mbr.CusId = reader["cusid"].ToString();
                     }
                     if (reader["cusdisplayname"].GetType().Name != "DBNull")
                     {
                         mbr.ScreenName = reader["cusdisplayname"].ToString();
                     }
                     isSynced = mbr.CusId == cusid;                      //if so, the cusid must be the same as the one passed in
                     if (isSynced && !string.IsNullOrEmpty(screenname))
                     {
                         isSynced = mbr.ScreenName == screenname;        //if screenname passed in it must match
                     }
                 }
             }
             else
             {
                 isSynced = true;                                    //we don't have that username - nothing to sync
             }
             reader.Close();
         }
     }
     return isSynced;
 }
        public BaseResponse UpdateMember(string 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,
            bool debug)
        {
            methodName = "UpdateMember";
            
            try
            {
                #region  set member data
                Member memberData = new Member();
                memberData.MemberId = memberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn = optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                #endregion

                //TODO :  Error handling for dupe email or screenname

                #region update ah db here
                using (HarperACL.ACLDataDataContext context = new ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {

                    HarperACL.Customer customer = (from a in context.Customers
                                                   join b in context.SFG_CustomerNumbers
                                                   on a.cusID equals b.cusID
                                                   where b.SFGCustNum == memberid
                                                   select a).Single();

                    int existing = (from a in context.Customers
                                    where
                                    (a.cusEmail == email || a.cusDisplayName == screenname)
                                    && a.cusID != customer.cusID
                                    select a).Count();
                    if (existing > 0)
                    {
                        throw new Exception("Unable to update member data, screen name or email already in use.");
                    }
                    customer.cusPrefix = salutation;
                    customer.cusFirstName = firstname;
                    customer.cusLastName = lastname;
                    customer.cusSuffix = suffix;
                    customer.cusTitle = professionaltitle;
                    customer.cusEmail = email;
                    customer.cusCompany = businessname;
                    customer.cusPhone1 = phone;
                    customer.cusDateUpdated = DateTime.Now;
                    customer.cusDisplayName = screenname;

                    HarperACL.AddressCustomer address = (from a in context.AddressCustomers
                                                         where a.addID == customer.addID
                                                         select a).Single();
                    address.addAddress1 = address1;
                    address.addAddress2 = address2;
                    address.addAddress3 = address3;
                    address.addCity = city;
                    address.addCountry = country;
                    address.addDateUpdated = DateTime.Now;
                    address.addPostalCode = postalcode;
                    address.addRegion = state;

                    context.SubmitChanges();
                }
                #endregion

                //update at SFG
                UpdateMemberRequest request = new UpdateMemberRequest(memberData, debug);
                baseResponse = CustomerUpdate.UpdateMember(request);
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            
            return baseResponse;
        }
        //string optin, string fax, string altcity,string giftoptin, string giftfax, string giftaltcity
        private object[] CreateSubscription(string subscriptionlength,
            string amountpaid, string verifoneroutingid,
            string publicationcode, string keycode,
            string renewingmemberid, string salutation, string firstname, string middleinitial, string lastname, string suffix,
            string professionaltitle, string email, string businessname, string address1, string address2, string address3,
            string city, string state, string postalcode, string country,
            string phone, 
            string giftflag,
            string renewinggiftmemberid, string giftsalutation, string giftfirstname, string giftmiddleinitial, string giftlastname, string giftsuffix,
            string giftprofessionaltitle, string giftemail, string giftbusinessname, string giftaddress1, string giftaddress2, string giftaddress3,
            string giftcity, string giftstate, string giftpostalcode, string giftcountry,
            string giftphone,
            string iscomp)
        {
            int response_code = 0;
            string member_id = string.Empty;

            #region convert string input to correct types

            bool is_comp = false;
            if (!bool.TryParse(iscomp, out is_comp))
            {
                is_comp = false;
            }
            int i_subscriptionlength = 0;
            float f_amountpaid = 0.0f;
            bool b_optin = false;
            bool b_giftflag = false;
            bool b_giftoptin = false;

            if (!int.TryParse(subscriptionlength, out i_subscriptionlength))
            {
                response_code = 401;
            }
            if (!float.TryParse(amountpaid, out f_amountpaid))
            {
                response_code = 402;
            }
            /*if (!bool.TryParse(optin, out b_optin))
            {
                response_code = 403;
            }*/
            if (!string.IsNullOrEmpty(giftflag))
            {
                if (!bool.TryParse(giftflag, out b_giftflag))
                {
                    response_code = 404;
                }
                /*if (!bool.TryParse(giftoptin, out b_giftoptin))
                {
                    response_code = 405;
                }*/
            }
            #endregion

            if (response_code == 0)
            {
                #region set member data
                Member memberData = new Member();
                memberData.MemberId = renewingmemberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.MiddleInitial = middleinitial;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn = b_optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                //memberData.Address.Fax = fax;
                //memberData.Address.AltCity = altcity;

                Member giftData = new Member();
                if (b_giftflag)
                {
                    giftData.MemberId = renewinggiftmemberid;
                    giftData.Salutation = salutation;
                    giftData.FirstName = firstname;
                    giftData.MiddleInitial = middleinitial;
                    giftData.LastName = lastname;
                    giftData.Suffix = suffix;
                    giftData.ProfessionalTitle = professionaltitle;
                    giftData.OptIn = b_giftoptin;
                    giftData.Email = email;

                    giftData.Address = new Address();
                    giftData.Address.BusinessName = businessname;
                    giftData.Address.Address1 = address1;
                    giftData.Address.Address2 = address2;
                    giftData.Address.Address3 = address3;
                    giftData.Address.City = city;
                    giftData.Address.State = state;
                    giftData.Address.PostalCode = postalcode;
                    giftData.Address.Country = country;
                    giftData.Address.Phone = phone;
                    //giftData.Address.Fax = fax;
                    //giftData.Address.AltCity = altcity;
                }
                #endregion

                #region set cc data
                CreditCard creditCardData = new CreditCard();
                creditCardData.Price = f_amountpaid;
                creditCardData.AmountPaid = f_amountpaid;
                creditCardData.VerifoneRoutingId = verifoneroutingid;
                
                if(is_comp)
                {
                    creditCardData.PaymentType = "F";
                }
                #endregion

                SubscriptionServiceRequest request = new SubscriptionServiceRequest(memberData, giftData, 
                    creditCardData, publicationcode, keycode, b_giftflag, i_subscriptionlength);
                BaseResponse sub_response = SubOrderInsert.CreateSubscription(request);
                if (sub_response == null || sub_response.TypedResponse == null || sub_response.TypedResponse.Success == false)
                {
                    string msgs = string.Empty;
                    foreach (Message s in sub_response.Messages)
                    {
                        msgs += "[" + s.ToString() + "]";
                    }
                    tbl_AppEventLog logmsg = new tbl_AppEventLog();
                    logmsg.aelAppName = "HarperSERVICE";
                    logmsg.aelDateCreated = DateTime.Now;
                    logmsg.aelEvent = "406";
                    logmsg.aelMessage1 = "sub_response messages:" + msgs;
                    logmsg.aelMessage2 = "typed response:" + sub_response.TypedResponse.ToString();
                    logmsg.aelMessage3 = "success:" + sub_response.TypedResponse.Success;
                    logmsg.Save();
                    response_code = 406;
                }
                else
                {
                    member_id = ((SubscriptionServiceResponse)sub_response.TypedResponse).MemberId;
                }
            }
            return new object[]{response_code, member_id};
        }
        //string optin,string fax,string altcity,
        private object[] ChargeCard(string memberid, string salutation, string firstname, string middleinitial, string lastname, string suffix,
            string professionaltitle, string email, string businessname, string address1, string address2, string address3,
            string city, string state, string postalcode, string country,
            string phone,  
            string ccnumber, string expmonth, string expyear, string amount,
            string ccname, string ccaddr, string cccity,
            string ccstate, string cczip, string cccountry, string pubcode, string username, string password, string refreshcustomer)
        {
            int response_code = 0;
            string routing_id = string.Empty;
            string auth_code = string.Empty;

            #region convert string input to correct types
            bool b_optin = false;
            short s_expmonth = 0;
            short s_expyear = 0;
            float f_amount = 0.0f;
            bool b_refreshcustomer = false;

            /*if (!bool.TryParse(optin, out b_optin))
            {
                response_code = 301;
            }*/
            if (!short.TryParse(expmonth, out s_expmonth))
            {
                response_code = 302;
            }
            if (!short.TryParse(expyear, out s_expyear))
            {
                response_code = 303;
            }
            if (!float.TryParse(amount, out f_amount))
            {
                response_code = 304;
            }
            if (!bool.TryParse(refreshcustomer, out b_refreshcustomer))
            {
                response_code = 305;
            }
            #endregion
            
            if(response_code == 0)
            {
                #region validate input
                Member memberData = new Member();
                memberData.MemberId = memberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.MiddleInitial = middleinitial;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                //memberData.OptIn = b_optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                //memberData.Address.Fax = fax;
                //memberData.Address.AltCity = altcity;

                CreditCard ccData = new CreditCard();
                ccData.CCNumber = ccnumber;
                ccData.CCExpMonth = s_expmonth;
                ccData.CCExpYear = s_expyear;
                ccData.AmountPaid = f_amount;
                ccData.CCName = ccname;
                ccData.CCAddress = ccaddr;
                ccData.CCCity = cccity;
                ccData.CCState = ccstate;
                ccData.CCPostalCode = cczip;
                ccData.CCCountry = cccountry;
                #endregion

                CreditCardServiceRequest request = new CreditCardServiceRequest(ccData, memberData, pubcode, username, password, b_refreshcustomer);
                BaseResponse cc_response = CreditCardProcessing.GetResponse(request);

                if (cc_response == null || cc_response.TypedResponse == null || cc_response.TypedResponse.Success == false)
                {
                    string msgs = string.Empty;
                    foreach (Message s in cc_response.Messages)
                    {
                        msgs += "[" + s.ToString() + "]";
                    }
                    tbl_AppEventLog logmsg = new tbl_AppEventLog();
                    logmsg.aelAppName = "HarperSERVICE";
                    logmsg.aelDateCreated = DateTime.Now;
                    logmsg.aelEvent = "306";
                    logmsg.aelMessage1 = "cc_response messages:" + msgs;
                    logmsg.aelMessage2 = "typed response:" + cc_response.TypedResponse.ToString();
                    logmsg.aelMessage3 = "success:" + cc_response.TypedResponse.Success;
                    logmsg.Save();
                    response_code = 306;
                }
                else
                {
                    routing_id = ((CreditCardServiceResponse)cc_response.TypedResponse).VerifoneRoutingId;
                    auth_code = ((CreditCardServiceResponse)cc_response.TypedResponse).AuthorizationCode;
                }
            }

            return new object[]{response_code, routing_id, auth_code};
        }
        private static Member GetMember(customerinfotype sfgObject)
        {
            EventLogger.LogEvent("ENTERING -> SFGWrapper.GateKeeperTranslators.GetMemberDetail()");
            Member ahObject = new Member();
            
            ahObject.Email = sfgObject.EMAIL;
            ahObject.Suffix = sfgObject.SUFFIX;
            ahObject.Salutation = sfgObject.TITLE;
            ahObject.FirstName = sfgObject.FIRST;
            ahObject.LastName = sfgObject.LAST;
            ahObject.MemberId = sfgObject.CUSTOMER_NUMBER;
            ahObject.MiddleInitial = (sfgObject.MI != null && sfgObject.MI.Length > 0) ? sfgObject.MI : null;
            ahObject.ProfessionalTitle = sfgObject.PROFESSIONAL_TITLE;
            ahObject.StatusFlag = sfgObject.STATUS;

            ahObject.Address.Address1 = sfgObject.ADD1;
            ahObject.Address.Address2 = sfgObject.ADD2;
            ahObject.Address.Address3 = sfgObject.ADD3;
            ahObject.Address.AltCity = sfgObject.ALTCITY;
            ahObject.Address.BusinessName = sfgObject.BUSINESS_NAME;
            ahObject.Address.City = sfgObject.CITY;
            ahObject.Address.Country = sfgObject.COUNTRY;
            ahObject.Address.Fax = ""; //TODO: NOT FOUND on sfgObject?
            ahObject.Address.Phone = sfgObject.PHONE;
            ahObject.Address.PostalCode = sfgObject.ZIP;
            ahObject.Address.State = sfgObject.STATE_NAME;
            ahObject.Address.StateCode = sfgObject.ST;

            ahObject.LoadHarperMemberData();

            EventLogger.LogEvent("LEAVING -> SFGWrapper.GateKeeperTranslators.GetMemberDetail()");
            return ahObject;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="memberToUpdate"></param>
 /// <param name="optIn"></param>
 /// <param name="debug"></param>
 public UpdateMemberRequest(Member memberToUpdate, bool debug)
 {
     base.Debug = debug;
     this.MemberToUpdate = memberToUpdate;
 }