partial void DeleteCustomer(Customer instance);
partial void InsertCustomer(Customer instance);
partial void UpdateCustomer(Customer instance);
/// <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; }