private void ProcessTypeFromExistingTopic(Type type) { if (IsValidString(type.Name)) { Type typeByName = typeRepository.GetByCondition(t => t.Name == type.Name && t.Topic.Name == type.Topic.Name); if (typeByName == null) { type.CreationDate = DateTime.Now; type.Id = Guid.NewGuid(); type.IsActive = true; type.AdditionalFields = new List <AdditionalField>(); type.Topic = topicRepository.GetByCondition(t => t.Name == type.Topic.Name && t.Area.Name == type.Topic.Area.Name); typeRepository.Add(type); typeRepository.SaveChanges(); } else { throw new ImportException($"Error on import: Type: {type.Name} from Topic: {type.Topic.Name} from Area: {type.Topic.Area.Name} already exists"); } } else { throw new ImportException($"Error on import: Type from Topic: {type.Topic.Name} from Area: {type.Topic.Area.Name} was invalid"); } }
private bool IsTypeRegistered(Type type) { type.Topic = topicRespository.Get(type.Topic.Id); Type typeInDB = typeRepository.GetByCondition(t => t.Name == type.Name && t.Topic == type.Topic); return(typeInDB != null); }