public async Task TogleFeature(FeatureDTO featureDTO) { if (!featureDTO.IsValid()) { await NotifyValidationErrors(featureDTO); return; } var existingFeature = await _featureRepository.GetByName(featureDTO.Name); if (existingFeature != null) { UpdateFeature(existingFeature, featureDTO); } else { await NotifyError(DomainMessageError.NonExistentFeature); } }
public async Task <Feature> AddFeature(FeatureDTO featureDTO) { if (!featureDTO.IsValid()) { await NotifyValidationErrors(featureDTO); return(null); } var existingFeature = await _featureRepository.GetByName(featureDTO.Name); if (existingFeature != null) { return(UpdateFeature(existingFeature, featureDTO)); } var feature = new Feature(featureDTO.Name, featureDTO.IsActive); _featureRepository.Add(feature); return(feature); }