Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        public void UpdateBasicData(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("数值不能为空");
            }
            BasicData entity = repository.GetId(dto.ID);

            if (entity == null)
            {
                throw new LogicException("修改数据不存在");
            }
            entity.DataValue = dto.DataValue;
            entity.IndexNo   = dto.IndexNo;
            entity.Name      = dto.Name;
            entity.Remark    = dto.Remark;
            entity.State     = dto.State;
            entity.Modified(this);
            repository.Update(entity);
            repository.UnitOfWork.Commit();
            resourceService.ChangedBasics();
        }
Ejemplo n.º 3
0
        public IActionResult GetBasicInfo(BasicDataDto model)
        {
            //待返回对象
            var result = new ResponseModel(ResponseCode.Error, "获取基础数据信息失败!");

            try
            {
                //实例化基础数据接口
                var BasicData = this.GetInstance <IBasicData>();
                result = BasicData.GetBasicDataInfo(model.编码, model.tabletype)?.Result;
            }
            catch (Exception ex)
            {
                LogError("服务器异常,查询基础数据失败", ex);
            }
            return(Json(result));
        }
Ejemplo n.º 4
0
        public IActionResult AddoUpdate(BasicDataDto model)
        {
            //待返回对象
            var result = new ResponseModel(ResponseCode.Error, "保存基础数据失败!");

            try
            {
                //重置简码
                model.简码 = Basics.Utils.Strings.GetFirstPY(model.称.Trim());
                //实例化基础数据接口
                var BasicData = this.GetInstance <IBasicData>();
                result = BasicData.UpdateDicItems(model.tabletype, model.编码, model.称, model.简码, model.oldcode, model.typeData)?.Result;
            }
            catch (Exception ex)
            {
                LogError("服务器异常,保存基础数据", ex);
            }
            return(Json(result));
        }
Ejemplo n.º 5
0
 public void AddBasicData([FromServices] BasicDataService service, [FromBody] BasicDataDto dto)
 {
     service.AddBasicData(dto);
 }
Ejemplo n.º 6
0
 public void UpdateBasicData([FromServices] BasicDataService service, [FromBody] BasicDataDto dto)
 {
     service.UpdateBasicData(dto);
 }