コード例 #1
0
        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;
        }        
コード例 #2
0
        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;
        }