Commit 47e5b923 by xin.yang

fix bug

parent 1452a0d0
......@@ -78,31 +78,50 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(RequestEnum.ParameterMiss);
}
if(!string.IsNullOrEmpty(req.parentid) && !string.IsNullOrEmpty(req.fixturetoolid) &&
req.parentid == req.fixturetoolid)
if(req.parentid == req.fixturetoolid)
{
throw new BadRequestException(RequestEnum.ParentSonSame);
}
var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId);
if (parent == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (son == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
var parentGuid = parent?.guid ?? "";
var parentGuid = parent.guid;
var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid);
if (exsit != null)
{
throw new BadRequestException(RequestEnum.DataExist);
}
if (!string.IsNullOrEmpty(parentGuid))
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if(parentExsit != null)
{
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if(parentExsit != null)
throw new BadRequestException(RequestEnum.LevelCountError);
}
if (_toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid) == null)
{
var parentEntity = new siger_automation_fixture_tools_assembly
{
throw new BadRequestException(RequestEnum.LevelCountError);
}
}
guid = Guid.NewGuid().ToString(),
parent = "",
son = parent.guid,
creator = UserId,
createtime = DateTime.Now,
attachment = req.fileurl,
filename = req.filename,
projectId = ProjectId,
updatetime = DateTime.Now,
updator = UserId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
};
_toolsAssemblyRepository.Insert(parentEntity);
}
var entity = new siger_automation_fixture_tools_assembly
{
......@@ -147,25 +166,45 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId);
if (parent == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (son == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
var parentGuid = parent?.guid ?? "";
var parentGuid = parent.guid;
var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid &&
q.id != req.id);
if (exsit != null)
{
throw new BadRequestException(RequestEnum.DataExist);
}
if (!string.IsNullOrEmpty(parentGuid))
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if (parentExsit != null)
{
throw new BadRequestException(RequestEnum.LevelCountError);
}
if (_toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid) == null)
{
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if (parentExsit != null)
var parentEntity = new siger_automation_fixture_tools_assembly
{
throw new BadRequestException(RequestEnum.LevelCountError);
}
guid = Guid.NewGuid().ToString(),
parent = "",
son = parent.guid,
creator = UserId,
createtime = DateTime.Now,
attachment = req.fileurl,
filename = req.filename,
projectId = ProjectId,
updatetime = DateTime.Now,
updator = UserId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
};
_toolsAssemblyRepository.Insert(parentEntity);
}
entity.parent = parent?.guid ?? "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment