Exemplo n.º 1
0
        /// <summary>Sets the base.</summary>
        /// <typeparam name="TAggregateRoot">The type of the t aggregate root.</typeparam>
        /// <param name="item">The item.</param>
        /// <param name="isAdd">if set to <c>true</c> [is add].</param>
        private void SetEntityBaseInfo <TAggregateRoot>(TAggregateRoot item, bool isAdd = true) where TAggregateRoot : EntityBase
        {
            IEntityBaseAutoSetter entityBaseAutoSetter = item.AutoSetter ?? new OperateSetter(_operateInfo);

            if (isAdd)//添加
            {
                if (item.Id <= 0L)
                {
                    item.Id = IdGenerateHelper.NewId;
                }
                item.CreateId   = entityBaseAutoSetter.CreateId;
                item.CreateTime = entityBaseAutoSetter.CreateTime;
                item.CreateName = entityBaseAutoSetter.CreateName;
            }
            else//编辑
            {
                item.UpdateId   = entityBaseAutoSetter.UpdateId;
                item.UpdateTime = entityBaseAutoSetter.UpdateTime;
                item.UpdateName = entityBaseAutoSetter.UpdateName;
            }
        }
Exemplo n.º 2
0
        /// <summary>Sets the base.</summary>
        /// <typeparam name="TAggregateRoot">The type of the t aggregate root.</typeparam>
        /// <param name="item">The item.</param>
        /// <param name="isAdd">if set to <c>true</c> [is add].</param>
        private void SetBase <TAggregateRoot>(TAggregateRoot item, bool isAdd = true) where TAggregateRoot : EntityBase
        {
            IEntityBaseAutoSetter entityBaseAutoSetter = item.AutoSetter ?? (IEntityBaseAutoSetter) new OperateSetter(this._operateContent);

            if (!isAdd)
            {
                item.UpdateId   = entityBaseAutoSetter.UpdateId;
                item.UpdateTime = entityBaseAutoSetter.UpdateTime;
                item.UpdateName = entityBaseAutoSetter.UpdateName;
            }
            else
            {
                if (item.Id <= 0L)
                {
                    item.Id = IdGenerateHelper.NewId;
                }
                item.CreateId   = entityBaseAutoSetter.CreateId;
                item.CreateTime = entityBaseAutoSetter.CreateTime;
                item.CreateName = entityBaseAutoSetter.CreateName;
                item.UpdateId   = entityBaseAutoSetter.UpdateId;
                item.UpdateTime = entityBaseAutoSetter.UpdateTime;
                item.UpdateName = entityBaseAutoSetter.UpdateName;
            }
        }