public bool Create(int dependentComponentType, Guid dependentObjectId, int requiredComponentType, params Guid[] requiredObjectId) { Guard.NotEmpty(requiredObjectId, nameof(requiredObjectId)); var existEntities = _dependencyRepository.Query(x => x.DependentComponentType == dependentComponentType && x.DependentObjectId == dependentObjectId && x.RequiredComponentType == requiredComponentType && x.RequiredObjectId.In(requiredObjectId))?.ToList(); List <Domain.Dependency> entities = new List <Domain.Dependency>(); foreach (var item in requiredObjectId) { if (item.Equals(Guid.Empty)) { continue; } if (existEntities != null && existEntities.Exists(x => x.DependentComponentType == dependentComponentType && x.DependentObjectId == dependentObjectId && x.RequiredComponentType == requiredComponentType && x.RequiredObjectId == item)) { continue; } var entity = new Domain.Dependency(); entity.DependencyId = Guid.NewGuid(); entity.DependentComponentType = dependentComponentType; entity.DependentObjectId = dependentObjectId; entity.RequiredComponentType = requiredComponentType; entity.RequiredObjectId = item; entities.Add(entity); } if (entities.NotEmpty()) { return(CreateMany(entities)); } return(false); }
public bool Create(Domain.Dependency entity) { if (_dependencyRepository.Exists(x => x.DependentComponentType == entity.DependentComponentType && x.DependentObjectId == entity.DependentObjectId && x.RequiredComponentType == entity.RequiredComponentType && x.RequiredObjectId == entity.RequiredObjectId)) { return(false); } return(_dependencyRepository.Create(entity)); }
public virtual DependencyBatchBuilder Append(int dependentComponentType, Guid dependentObjectId, int requiredComponentType, params Guid[] requiredObjectId) { if (requiredObjectId.NotEmpty()) { foreach (var item in requiredObjectId) { var entity = new Domain.Dependency { DependentComponentType = dependentComponentType, DependentObjectId = dependentObjectId, RequiredComponentType = requiredComponentType, RequiredObjectId = item }; _entities.Add(entity); } } return(this); }
public bool Update(Domain.Dependency entity) { return(_dependencyRepository.Update(entity)); }