Commit f9b4e17e by yiyu.li
parents a07dad2b 7ca6b796
......@@ -248,11 +248,16 @@ namespace Siger.ApiACC.Controllers
[HttpGet]
public IActionResult Delete(int id)
{
var entity = _toolsRepository.Get(q => q.projectId == ProjectId && q.id == id);
var entity = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.id == id);
if (entity == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var sons = _toolsAssemblyRepository.GetList(q => q.projectId == ProjectId && q.parent == entity.son).ToList();
foreach(var son in sons)
{
_toolsAssemblyRepository.Delete(son);
}
_toolsAssemblyRepository.Delete(entity);
if (_unitOfWork.Commit() > 0)
{
......@@ -276,14 +281,24 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
var sons = _toolsAssemblyRepository.GetList(q => q.projectId == ProjectId && entities.Select(t => t.son).Contains(q.parent)).ToList();
foreach (var son in sons)
{
_toolsAssemblyRepository.Delete(son);
}
foreach (var entity in entities)
{
_toolsAssemblyRepository.Delete(entity);
}
if (_unitOfWork.Commit() > 0)
{
return new ObjectResult(CommonEnum.Succefull);
throw new BadRequestException(CommonEnum.Fail);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
}
}
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