public ValidationResult CollectValidationResultBeforePersist(ProjectDto projectDto) { ValidationResult validationResult = new ValidationResult(); validationResult.AddRange(CollectIsNameUniqueValidationMessage(projectDto)); return(validationResult); }
public ValidationResult CollectValidationResultBeforeDelete(CompositeType compositeType) { ValidationResult validationResult = new ValidationResult(); List <CompositeTypeElement> compositeTypeElementWhereTypeIsUsedAsElementType = _compositeTypeElementRepository.FindCompositeTypeElementsToElementTypeId(compositeType.Id); if (compositeTypeElementWhereTypeIsUsedAsElementType.Count != 0) { validationResult.AddRange(CreateValidationMessage(ValidationType.ERROR, MessageKeyConstants.VALIDATION_MESSAGE_TYPE_IS_USED_AS_TYPE_ELEMENT, compositeTypeElementWhereTypeIsUsedAsElementType, compositeType)); } List <CompositeType> compositeTypesWhereTypeIsUsedAsSuperType = _compositeTypeRepository.FindCompositeTypesWhereIsUsedTypeInSuperTypes(compositeType.Id); if (compositeTypesWhereTypeIsUsedAsSuperType.Count != 0) { validationResult.AddRange(CreateValidationMessage(ValidationType.ERROR, MessageKeyConstants.VALIDATION_MESSAGE_TYPE_IS_USED_AS_SUPER_TYPE, compositeTypesWhereTypeIsUsedAsSuperType, compositeType)); } return(validationResult); }
public ValidationResult CollectValidationResultBeforeDelete(Folder folder) { ValidationResult validationResult = new ValidationResult(); List <Guid> folderIds = _folderRepository.FindAllSubFolderIds(folder.Id); List <CompositeType> compositeTypes = _compositeTypeRepository.FindCompositeTypesToFolderIds(folderIds); List <ValidationMessage> validationMessages = CollectInvalidCompositeTypesUsedInSuperTypesValidationMessages(folderIds, compositeTypes); validationMessages.AddRange(CollectInvalidCompositeTypesOwnerOfCompositeTypeElementsUsedAsElementType(folderIds, compositeTypes)); validationResult.AddRange(validationMessages); return(validationResult); }
public ValidationResult CollectValidationResultBeforeDelete(Preset preset) { ValidationResult validationResult = new ValidationResult(); List <CompositePresetElement> compositePresetElements = _compositePresetElementRepository.FindCompositePresetElementToAssociatedPreset(preset.Id); if (compositePresetElements.Count != 0) { validationResult.AddRange(CreateValidationMessage(ValidationType.ERROR, MessageKeyConstants.VALIDATION_MESSAGE_PRESET_IS_ASSOCIATED_TO_PRESET_ELEMENT, compositePresetElements, preset)); } return(validationResult); }
public bool Validate() { ValidationResult.Clear(); // Forms foreach (var fm in Model.Forms.Select(f => f.Model).Where(f => f != null)) { var formsValidations = _formBuilderController.Validate(fm); fm.Validated = !formsValidations.Any(v => v.Type == ValidationResultTypes.Error); var formItems = formsValidations.Select(r => new ValidationOutputItem(r, ValidationLocationType.Form)).ToList(); ValidationResult.AddRange(formItems); } var fail = ValidationResult.Any(); return(!fail); }
private StoreCodeGeneratorContext GetCodeGenerationContext() { var ctx = new StoreCodeGeneratorContext(); // ToDo: we implement code generation of the fly - all changes made but not save should be reflected // ToDo: schemas should be taken from current model changes, for now we take originals ctx.Schemas = Model.Schemas.ToDictionary(m => m.Schema.Name, m => m.Schema); ctx.Queries = Model.Queries.ToDictionary(m => m.Query.Name, m => m.Query); // forms on the fly generation reflecting not saved changes ctx.Forms = new Dictionary <string, StoreForm>(); ValidationResult.Clear(); foreach (var formDetails in Model.Forms) { StoreForm storeForm = formDetails.Form; var formModel = (formDetails)?.Model; if (formModel != null) { var formsValidations = _formBuilderController.Validate(formModel); formModel.Validated = !formsValidations.Any(v => v.Type == ValidationResultTypes.Error); if (formModel.Validated) { // use changes if pass validation storeForm = formModel.ToStore(); } else { // validation failed - use original form var formItems = formsValidations.Select(r => new ValidationOutputItem(r, ValidationLocationType.Form)).ToList(); ValidationResult.AddRange(formItems); } } ctx.Forms[storeForm.Name] = storeForm; } return(ctx); }
private void ShowGeneratedFormCode(EditWindowDetails wnd) { // Validate form before generateion var formDetails = wnd.StoreObjectDetails as FormDetails; var formModel = (formDetails)?.Model; var formsValidations = _formBuilderController.Validate(formModel); formModel.Validated = !formsValidations.Any(v => v.Type == ValidationResultTypes.Error); if (!formModel.Validated) { var formItems = formsValidations.Select(r => new ValidationOutputItem(r, ValidationLocationType.Form)).ToList(); ValidationResult.Clear(); ValidationResult.AddRange(formItems); OpenSpecialWindow("Output", EditWindowType.Output); return; } var storeForm = formModel.ToStore(); var ctx = GetCodeGenerationContext(); var code = formModel.IsListForm ? new CodeGenerationSection[] { _formCodeGenerator.GenerateListFormRazorPage(storeForm, ctx), _formCodeGenerator.GenerateListForm(storeForm, ctx) } : new CodeGenerationSection[] { _formCodeGenerator.GenerateEditFormRazorPage(storeForm, ctx), _formCodeGenerator.GenerateEditForm(storeForm, ctx) }; var name = $"Code preview: {ActiveWindow.StoreObject.Name}"; var w = Model.EditWindows.FirstOrDefault(x => x.Type == EditWindowType.CodePreview && x.StoreObject.Name == name); if (w != null) { w.StoreObject = new SpecialWindowStoreObject { Name = name, Content = new CodePreviewSpecialWindowContent(code) }; } OpenSpecialWindow(name, EditWindowType.CodePreview, new CodePreviewSpecialWindowContent(code)); }
public ValidationResult Validate(ICertificate certificate) { var result = new ValidationResult(); if (certificate == null) return result; result.Add("Отпечаток сертификата", certificate.Thumbprint); result.Add("Серийный номер сертификата", certificate.SerialNumber); result.AddNewLine(2); result.AddRange(new CertificateCommonValidator().Validate(certificate)); result.AddNewLine(2); result.AddRange(new CertificateChainValidator().Validate(certificate)); result.AddNewLine(2); result.AddRange(new CertificateQualifiedValidator().Validate(certificate)); return result; }