protected override async Task BaseValidation(UpdateCollectionModel model) { var collections = await collectionsCrudService.GetAllAsync(); if (!collections.Any(c => c.Id == model.CollectionId)) { ValidationResult.AddError("Collection not found"); } if (collections.Any(c => c.Name == model.Name && c.Id != model.CollectionId)) { ValidationResult.AddError("Collection with such name already exists"); } var owner = await userCrudService.GetAsync(model.OwnerId); if (owner is null) { ValidationResult.AddError("User not found"); } var resource = await resourceCrudService.GetAsync(model.ResourceId); if (resource is null) { ValidationResult.AddError("Resource not found"); } var theme = await themesCrudService.GetAsync(model.ThemeId); if (theme is null) { ValidationResult.AddError("Theme not found"); } }
protected async override Task BaseValidation(DeleteThemeModel model) { var theme = await themesCrudService.GetAsync(model.ThemeId); if (theme is null) { ValidationResult.AddError("Theme not found"); } }
protected async override Task BaseValidation(CreateCollectionModel model) { var owner = await userCrudService.GetAsync(model.OwnerId); if (owner is null) { ValidationResult.Errors.Add("User not found"); } var resource = await resourceCrudService.GetAsync(model.ResourceId); if (resource is null) { ValidationResult.AddError("Resource not found"); } var theme = await themesCrudService.GetAsync(model.ThemeId); if (theme is null) { ValidationResult.Errors.Add("Theme not found"); } }