Example #1
0
        public async Task <Address> CreateAddress(AddressContent address)
        {
            AddressContent content = new AddressContent
            {
                AddressLine1        = address.AddressLine1,
                AddressLine2        = address.AddressLine2,
                Name                = address.Name,
                City                = address.City,
                StateProvinceRegion = address.StateProvinceRegion,
                Country             = address.Country,
                Postal              = address.Postal,
                PlatformIdentifier  = _platformIdentifier,
                IsInternational     = address.IsInternational,
                Owner               = new Owner {
                    Collection = address.Owner.Collection, Identifier = address.Owner.Identifier
                }
            };

            Address newEntity = new Address
            {
                Contents = content
            };

            var entity = await _context.Address.AddAsync(newEntity);

            return(entity);
        }
Example #2
0
        public static void AddAddress(this User user, MembershipService service, AddressCreate address)
        {
            var createAddress = new AddressContent
            {
                AddressLine1        = address.AddressLine1,
                AddressLine2        = address.AddressLine2,
                Name                = address.Name,
                StateProvinceRegion = address.StateProvinceRegion,
                City                = address.City,
                Country             = address.Country,
                Postal              = address.Postal,
                IsInternational     = address.IsInternational,
                Owner               = user.ConstuctOwner(address.IsAccountMasterLevel, service)
            };
            var newAddress = service.CreateAddress(createAddress).Result;

            if (address.setAsDefault)
            {
                user.Contents.DefaultAddressIdentifier = newAddress.Contents.Identifier;
                user = service.UpdateUser(user).Result;
            }
        }
Example #3
0
 public void CreateUserWithAddress()
 {
     var login         = sConfig.CreateLogin("*****@*****.**").Result;
     var accountMaster = sMember.CreateAccountMaster("Softtek QA Test", true).Result;
     var account       = sMember.CreateAccount(accountMaster.Contents.Identifier).Result;
     var contact       = sMember.CreateContact(account.Contents.Identifier, "test", "test", "1278023", "*****@*****.**").Result;
     var user          = sMember.CreateUser(account.Contents.Identifier, login.Contents.Identifier, contact.Contents.Identifier).Result;
     var newAddress    = new AddressContent
     {
         AddressLine1        = "Walnut Street",
         AddressLine2        = "07",
         Name                = "QA Softtek",
         StateProvinceRegion = "CO",
         City                = "Denver",
         Country             = "US",
         Postal              = "12345",
         IsInternational     = false,
         Owner               = new Owner {
             Collection = "User", Identifier = user.Contents.Identifier
         }
     };
     var address = sMember.CreateAddress(newAddress).Result;
 }
Example #4
0
        /// <summary>
        /// 获取帖子内容块列表
        /// </summary>
        /// <param name="sourceTopicContent"></param>
        /// <returns></returns>
        private static List <TopicContent> GetTopicContentList(this string sourceTopicContent)
        {
            List <TopicContent> contentList = new List <TopicContent>(0);

            if (!string.IsNullOrEmpty(sourceTopicContent) && sourceTopicContent.StartsWith("<TopicContent>") && sourceTopicContent.EndsWith("</TopicContent>"))
            {
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(sourceTopicContent.Trim());
                    XmlNode rootNode = xmlDoc.SelectSingleNode("TopicContent");
                    if (null != rootNode && rootNode.HasChildNodes)
                    {
                        foreach (XmlNode node in rootNode.ChildNodes)
                        {
                            if (node.NodeType == XmlNodeType.Element)
                            {
                                //ContentType ct = (ContentType)Enum.Parse(typeof(ContentType), node.Name, true);
                                ContentType ct   = GetTopicContentType(node.Name);
                                byte[]      data = null;
                                switch (ct)
                                {
                                case ContentType.Image:
                                    ImageContent imageContent = node.GetImageContent();
                                    if (null != imageContent)
                                    {
                                        data = imageContent.ProtoBufSerialize <ImageContent>();
                                    }
                                    break;

                                case ContentType.Voice:
                                    VoiceContent voiceContent = node.GetVoiceContent();
                                    if (null != voiceContent)
                                    {
                                        data = voiceContent.ProtoBufSerialize <VoiceContent>();
                                    }
                                    break;

                                case ContentType.Video:
                                    VideoContent videoContent = node.GetVideoContent();
                                    if (null != videoContent)
                                    {
                                        data = videoContent.ProtoBufSerialize <VideoContent>();
                                    }
                                    break;

                                case ContentType.Address:
                                    AddressContent addressContent = node.GetAddressContent();
                                    if (null != addressContent)
                                    {
                                        data = addressContent.ProtoBufSerialize <AddressContent>();
                                    }
                                    break;

                                case ContentType.Telphone:
                                    TelphoneContent telphoneContent = node.GetTelphoneContent();
                                    if (null != telphoneContent)
                                    {
                                        data = telphoneContent.ProtoBufSerialize <TelphoneContent>();
                                    }
                                    break;

                                case ContentType.Contact:
                                    ContactContent contactContent = node.GetContactContent();
                                    if (null != contactContent)
                                    {
                                        data = contactContent.ProtoBufSerialize <ContactContent>();
                                    }
                                    break;

                                case ContentType.Text:
                                default:
                                    TextContent textContent = node.GetTextContent();
                                    if (null != textContent)
                                    {
                                        data = textContent.ProtoBufSerialize <TextContent>();
                                    }
                                    break;
                                }

                                TopicContent content = new TopicContent {
                                    ContentType = ct, Data = data
                                };
                                contentList.Add(content);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex.Error();
                }
            }
            return(contentList);
        }