public async Task <BlResult> DeleteAsync(int id) { BlResult blResult = new BlResult(); try { var entity = await _graphRepository.GetByIdWithReferencAsync(id); if (entity != null) { if (entity.Nodes.Count > 0) { blResult.Fail(ConstDictionary.CantDeleteGraphWithChildes); } else { EnsureTransaction(); _graphRepository.Delete(id); await SaveChangesAsync(); blResult.Success(); } } else { throw new ArgumentException(); } } catch (ArgumentException) { blResult.Fail(BLErrorCodeTypeEnum.NoSuchEntityExistsWithID); } catch (Exception ex) { blResult.Fail(BLErrorCodeTypeEnum.Unknown, ex); } return(blResult); }