Ejemplo n.º 1
0
        /// <summary>
        /// 添加Parent及其EasyChatTime
        /// </summary>
        /// <param name="contact"></param>
        /// <param name="studentID"></param>
        void AddParentAndChattime(EasyChatTimeModel contact, Guid studentID)
        {
            StudentParentEntity other = new StudentParentEntity
            {
                ParentID = Guid.NewGuid(),
                StudentID = studentID,
                NameCn = contact.ContactIdentity.NameCn,
                Email = contact.ContactIdentity.Email,
                Mobile = contact.ContactIdentity.Mobile,
                PersonIdentity = (PersonIdentity)Enum.Parse(typeof(PersonIdentity), contact.ContactIdentity.PersonIdentity)
            };
            repository.SaveStudentParent(other);    //添加Parent信息

            foreach (EasyChatTimeEntity item in contact.EasyChatTimes)
            {
                item.IfParentID = other.ParentID;
                repository.SaveEasyChatTime(item);  //添加EasyChatTime信息
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 返回EasyChatTimeModel
        /// </summary>
        /// <param name="identity">身份</param>
        /// <param name="nameCn">中文名</param>
        /// <param name="email">邮箱</param>
        /// <param name="mobile">电话</param>
        /// <param name="personId">id</param>
        /// <returns></returns>
        public EasyChatTimeModel ReturnEasyChatTimeModel(PersonIdentity identity, string nameCn, string email, string mobile, Guid personId)
        {
            EasyChatTimeModel returnModel = new EasyChatTimeModel();
            ContactIdentity contact = new ContactIdentity
            {
                PersonIdentity = identity.ToString(),
                NameCn = nameCn,
                Email = email,
                Mobile = mobile
            };
            IEnumerable<EasyChatTimeEntity> easyChatTimes = null;

            if (identity == PersonIdentity.学生)
                easyChatTimes = repository.EasyChatTime.Where(e => e.IfStudentID == personId).Select(e => e);
            else
                easyChatTimes = repository.EasyChatTime.Where(e => e.IfParentID == personId).Select(e => e);

            returnModel.ContactIdentity = contact;
            returnModel.EasyChatTimes = easyChatTimes;
            return returnModel;
        }