public IActionResult Create([FromBody] ProductProcessCreateDto parm) { try { var process = parm.Adapt <Base_ProductProcess>().ToCreate(_tokenManager.GetSessionInfo()); if (_processService.Any(m => m.ProcessNo == parm.ProcessNo)) { return(toResponse(StatusCodeType.Error, $"添加工序编码 {parm.ProcessNo} 已存在,不能重复!")); } //从 Dto 映射到 实体 _unitOfWork.BeginTran(); var response = _processService.Add(process); //插入关系表 _dataRelationService.Add(new Sys_DataRelation { ID = GetGUID, Form = process.ID, To = parm.WorkShopUID, Type = DataRelationType.Process_To_WorkShop.ToString() }); _unitOfWork.CommitTran(); return(toResponse(response)); } catch (Exception) { _unitOfWork.RollbackTran(); throw; } }
public IActionResult Create([FromBody] WorkShopCreateDto parm) { try { var workshop = parm.Adapt <Base_WorkShop>().ToCreate(_tokenManager.GetSessionInfo()); if (_workShopService.Any(workshop.ID, parm.WorkShopNo, parm.FactoryUID)) { return(toResponse(StatusCodeType.Error, $"添加车间编码 {parm.WorkShopNo} 已存在,不能重复!")); } //从 Dto 映射到 实体 _dataRelationService.BeginTran(); var response = _workShopService.Add(workshop); //插入关系表 _dataRelationService.Add(new Sys_DataRelation { ID = GetGUID, Form = workshop.ID, To = parm.FactoryUID, Type = DataRelationType.WorkShop_To_Factory.ToString() }); _dataRelationService.CommitTran(); return(toResponse(response)); } catch (Exception) { _dataRelationService.RollbackTran(); throw; } }
public IActionResult Create([FromBody] EquipmentCreateDto parm) { try { var line = parm.Adapt <Base_Equipment>().ToCreate(_tokenManager.GetSessionInfo()); if (_equipmentService.Any(m => m.EquipNo == parm.EquipNo)) { return(toResponse(StatusCodeType.Error, $"添加机台编码 {parm.EquipNo} 已存在,不能重复!")); } //从 Dto 映射到 实体 _dataRelationService.BeginTran(); var response = _equipmentService.Add(line); //插入关系表 _dataRelationService.Add(new Sys_DataRelation { ID = GetGUID, Form = line.ID, To = parm.LineUID, Type = DataRelationType.Equipment_To_Line.ToString() }); _dataRelationService.CommitTran(); return(toResponse(response)); } catch (Exception ex) { _dataRelationService.RollbackTran(); throw ex; } }
public IActionResult Create([FromBody] FactoryCreateDto parm) { try { var factory = parm.Adapt <Base_Factory>().ToCreate(_tokenManager.GetSessionInfo()); if (_factoryService.Any(m => m.FactoryNo == parm.FactoryNo)) { return(toResponse(StatusCodeType.Error, $"添加工厂编码 {parm.FactoryNo} 已存在,不能重复!")); } //从 Dto 映射到 实体 _dataRelationService.BeginTran(); var response = _factoryService.Add(factory); //插入关系表 _dataRelationService.Add(new Sys_DataRelation { ID = GetGUID, Form = factory.ID, To = parm.CompanyUID, Type = DataRelationType.Factory_To_Company.ToString() }); _dataRelationService.CommitTran(); return(toResponse(response)); } catch (Exception ex) { _dataRelationService.RollbackTran(); throw ex; } }