/// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        protected override IDictionary <string, object> Convert(BossComment model)
        {
            var sqlParams = base.Convert(model);

            sqlParams["Images"] = model.Images == null ? null : model.Images.ToJson();
            return(sqlParams);
        }
        public static BossCommentEntity ToEntity(this BossComment item)
        {
            if (null == item)
            {
                return(null);
            }

            var entInfo = EntInfo.FindById(item.CommentEntId);

            var entity = new BossCommentEntity(item, entInfo);

            return(entity);
        }
Beispiel #3
0
        public static TargetEmployeEntity ToEntity(this TargetEmploye item)
        {
            if (null == item)
            {
                return(null);
            }

            var comments = BossComment.FindByEmployeId(item.EmployeId, new Pagination());

            var entity = new TargetEmployeEntity(item, comments.ToEntities());

            return(entity);
        }
        internal BossCommentEntity(BossComment source, EntInfo entInfo)
        {
            this.SetPropertyValues(source.GetPropertyValues());
            //this.EntName = entInfo.EntName;


            if (false == string.IsNullOrEmpty(source.Voice))
            {
                this.Voice = ImageHelper.ToAbsoluteUri(source.Voice);
            }

            if (null != source.Images && source.Images.Length > 0)
            {
                for (var i = 0; i < source.Images.Length; i++)
                {
                    this.Images[i] = ImageHelper.ToAbsoluteUri(source.Images[i]);
                }
            }
        }
Beispiel #5
0
        public long Post([FromBody] BossCommentEntity entity)
        {
            if (null == entity)
            {
                return(-1);
            }
            if (string.IsNullOrEmpty(entity.TargetIDCard))
            {
                return(-1);
            }

            var target = TargetEmploye.FindByIDCard(entity.TargetIDCard);

            if (null == target)
            {
                target          = new TargetEmploye();
                target.RealName = entity.TargetName;
                target.IDCard   = entity.TargetIDCard;
                target.Tags     = new string[] { target.RealName, target.IDCard.Substring(0, target.IDCard.Length > 6 ? 6 : target.IDCard.Length) };
                target.Save();
            }
            else if (target.RealName != entity.TargetName)
            {
                target.RealName = entity.TargetName;
                target.Save();
            }

            var userProfile = MvcContext.Current.UserPassport.Profile;
            var model       = new BossComment();

            model.FillPropertiesFromEntity(entity, true);
            var request = OpenAccountRequest.FindByPassportId(userProfile.PassportId);

            model.EmployeId           = target.EmployeId;
            model.CommentEntId        = 0;// EntInfo.FindByEntName(request.EntName).EntId;
            model.CommentatorId       = userProfile.PassportId;
            model.CommentatorName     = userProfile.RealName;
            model.CommentatorJobTitle = userProfile.CurrentJobTitle;

            var saved = model.Save();

            if (saved && (false == string.IsNullOrEmpty(entity.Voice) || null != entity.Images))
            {
                if (false == string.IsNullOrEmpty(entity.Voice))
                {
                    model.Voice = ImageHelper.SaveBossCommentVoice(model.CommentId, model.CreatedTime, entity.Voice) + "?t=" + DateTime.Now.ToString("yyMMddHHmmssfff");
                }

                if (null != entity.Images && entity.Images.Length > 0)
                {
                    string[] applyImages = null == entity.Images ? null : new string[entity.Images.Length];
                    if (null != entity.Images)
                    {
                        for (var i = 0; i < entity.Images.Length; i++)
                        {
                            var imageUrl = ImageHelper.SaveBossCommentImage(model.CommentId, model.CreatedTime, entity.Images[i]);
                            applyImages[i] = imageUrl + "?t=" + DateTime.Now.ToString("yyMMddHHmmssfff");
                        }
                        model.Images = applyImages;
                    }
                }

                saved = model.Save();
            }

            return(model.CommentId);
        }