コード例 #1
0
        public async Task TogleApplicationFeature(ApplicationFeatureDTO applicationFeatureDTO)
        {
            if (!applicationFeatureDTO.IsValid())
            {
                return;
            }

            var existingFeature = await _applicationFeatureRepository.GetAsync(applicationFeatureDTO.Application.Id, applicationFeatureDTO.Feature.Id);

            if (existingFeature != null)
            {
                UpdateApplicationFeature(existingFeature, applicationFeatureDTO);
            }
            else
            {
                await NotifyError(DomainMessageError.NonExistentFeature);
            }
        }
コード例 #2
0
        public async Task <ApplicationFeature> Add(ApplicationFeatureDTO applicationFeatureDTO)
        {
            if (!applicationFeatureDTO.IsValid())
            {
                await NotifyValidationErrors(applicationFeatureDTO);

                return(null);
            }

            var existingFeature = await _applicationFeatureRepository.GetAsync(applicationFeatureDTO.Application.Id, applicationFeatureDTO.Feature.Id);

            if (existingFeature != null)
            {
                return(UpdateApplicationFeature(existingFeature, applicationFeatureDTO));
            }

            var applicationFeature = new ApplicationFeature(applicationFeatureDTO.Feature, applicationFeatureDTO.Application, applicationFeatureDTO.IsActive);

            _applicationFeatureRepository.Add(applicationFeature);

            return(applicationFeature);
        }