Example #1
0
        public void AddBasicData(BasicDataDto dto)
        {
            long parentID = dto.ParentID;

            if (parentID <= 0)
            {
                throw new LogicException("上级编号无效");
            }
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new LogicException("名稱不能为空");
            }
            if (string.IsNullOrEmpty(dto.DataValue))
            {
                throw new LogicException("数值不能为空");
            }
            var entity = new BasicData
            {
                State     = CommonState.Enabled,
                Name      = dto.Name,
                ParentId  = parentID,
                DataValue = dto.DataValue,
                Remark    = dto.Remark
            };

            entity.Created(this);
            repository.Add(entity);
            repository.UnitOfWork.Commit();
            resourceService.ChangedBasics();
        }