Saturday, 8 September 2012

 OperationContext context = OperationContext.Current;
                        MessageProperties messageProperties = context.IncomingMessageProperties;
                        RemoteEndpointMessageProperty endpointProperty =
                          messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

                        string ipaddress = endpointProperty.Address;
                        //WebOperationContext.Current.OutgoingResponse.Headers.Add("datingUserID:"+userID);
                        var ipAddressIDDetails = from ipaddressdetails in dbDating.IPAddressDetails
                                                 where
                                                   ipaddressdetails.userID == userID &&
                                                   ipaddressdetails.IPAddressTypeID == 3 &&
                                                   ipaddressdetails.IPAddress == ipaddress
                                                 select new
                                                 {
                                                     ipaddressdetails.IPAddressID
                                                 };
                        if (ipAddressIDDetails.Count() == 0)
                        {
                            IPAddressDetail ipad = new IPAddressDetail
                            {
                                IPAddress = ipaddress,
                                IPAddressTypeID = 3,
                                userID = userID,
                                IPAddressDate = DateTime.Now
                            };

                            dbDating.IPAddressDetails.InsertOnSubmit(ipad);