Exemple #1
0
        public async Task <Contact> CreateContact(Guid accountId, string firstName, string lastName, string phoneNumber, string email)
        {
            ContactContent content = new ContactContent(accountId);

            content.FirstName    = firstName;
            content.LastName     = lastName;
            content.PhoneNumber  = phoneNumber;
            content.ContactEmail = email;

            Contact newEntity = new Contact
            {
                Contents = content
            };

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

            return(entity);
        }
Exemple #2
0
        /// <summary>
        /// 提取联系人内容
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private static ContactContent GetContactContent(this XmlNode node)
        {
            ContactContent content = new ContactContent {
                ShowText = node.InnerText.Trim()
            };
            string user   = node.Attributes["User"] == null ? "0" : node.Attributes["User"].Value;
            int    userId = 0;

            if (int.TryParse(user, out userId) && userId > 0)
            {
                UserCacheInfo userCache = UserBiz.ReadUserCacheInfo(userId);
                if (userCache != null)
                {
                    content.UserData = userCache.ToUserBase();
                }
            }
            return(content);
        }
Exemple #3
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);
        }
 public void Post([FromBody] ContactContent value)
 {
     _contactHubContext.Clients.All.SendAsync("OnIceReceived", value);
 }
 public void UpdateContactContent(ContactContent contactContent)
 {
     _iContactContentRepository.Update(contactContent);
     Save();
 }
 public void CreateContactContent(ContactContent contactContent)
 {
     _iContactContentRepository.Add(contactContent);
     Save();
 }
 public IActionResult Index(Node node, ContactContent content)
 {
     return(View());
 }
 public void UpdateContactContent(ContactContent contactContent)
 {
     _iContactContentRepository.Update(contactContent);
     Save();
 }
 public void CreateContactContent(ContactContent contactContent)
 {
     _iContactContentRepository.Add(contactContent);
     Save();
 }