diff --git a/PinkParrot.sln.DotSettings b/PinkParrot.sln.DotSettings
index 8f7549b08..94cc32e31 100644
--- a/PinkParrot.sln.DotSettings
+++ b/PinkParrot.sln.DotSettings
@@ -28,6 +28,7 @@
SUGGESTION
DO_NOT_SHOW
TypeScript16
+ <?xml version="1.0" encoding="utf-16"?><Profile name="Header"><CSUpdateFileHeader>True</CSUpdateFileHeader></Profile>
<?xml version="1.0" encoding="utf-16"?><Profile name="Namespaces"><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSUpdateFileHeader>True</CSUpdateFileHeader></Profile>
<?xml version="1.0" encoding="utf-16"?><Profile name="Typescript"><JsInsertSemicolon>True</JsInsertSemicolon><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor><CorrectVariableKindsDescriptor>True</CorrectVariableKindsDescriptor><VariablesToInnerScopesDescriptor>True</VariablesToInnerScopesDescriptor><StringToTemplatesDescriptor>True</StringToTemplatesDescriptor><RemoveRedundantQualifiersTs>True</RemoveRedundantQualifiersTs><OptimizeImportsTs>True</OptimizeImportsTs></Profile>
diff --git a/src/PinkParrot/Configurations/InfrastructureModule.cs b/src/PinkParrot/Configurations/InfrastructureModule.cs
index 302b60649..5e9ba3095 100644
--- a/src/PinkParrot/Configurations/InfrastructureModule.cs
+++ b/src/PinkParrot/Configurations/InfrastructureModule.cs
@@ -15,7 +15,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using MongoDB.Driver;
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
using PinkParrot.Infrastructure.CQRS.Autofac;
using PinkParrot.Infrastructure.CQRS.Commands;
using PinkParrot.Infrastructure.CQRS.EventStore;
@@ -58,7 +58,7 @@ namespace PinkParrot.Configurations
.As()
.SingleInstance();
- builder.RegisterType()
+ builder.RegisterType()
.As()
.SingleInstance();
@@ -86,7 +86,7 @@ namespace PinkParrot.Configurations
.AsSelf()
.SingleInstance();
- builder.RegisterType()
+ builder.RegisterType()
.AsSelf()
.SingleInstance();
}
diff --git a/src/PinkParrot/Configurations/ReadModule.cs b/src/PinkParrot/Configurations/ReadModule.cs
index 208545cc9..61584a378 100644
--- a/src/PinkParrot/Configurations/ReadModule.cs
+++ b/src/PinkParrot/Configurations/ReadModule.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ReadDependencies.cs
+// ReadModule.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -23,13 +23,13 @@ namespace PinkParrot.Configurations
.As()
.SingleInstance();
- builder.RegisterType()
- .As()
+ builder.RegisterType()
+ .As()
.As()
.SingleInstance();
- builder.RegisterType()
- .As()
+ builder.RegisterType()
+ .As()
.As()
.SingleInstance();
}
diff --git a/src/PinkParrot/Configurations/Serializers.cs b/src/PinkParrot/Configurations/Serializers.cs
index 319c79019..e03d772cb 100644
--- a/src/PinkParrot/Configurations/Serializers.cs
+++ b/src/PinkParrot/Configurations/Serializers.cs
@@ -10,8 +10,8 @@ using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
-using PinkParrot.Core.Schema;
-using PinkParrot.Events.Schema;
+using PinkParrot.Core.Schemas;
+using PinkParrot.Events.Schemas;
using PinkParrot.Infrastructure;
using PinkParrot.Infrastructure.CQRS.EventStore;
using PinkParrot.Infrastructure.Json;
@@ -45,8 +45,8 @@ namespace PinkParrot.Configurations
public static void AddEventFormatter(this IServiceCollection services)
{
- TypeNameRegistry.Map(typeof(ModelSchema).GetTypeInfo().Assembly);
- TypeNameRegistry.Map(typeof(ModelSchemaCreated).GetTypeInfo().Assembly);
+ TypeNameRegistry.Map(typeof(Schema).GetTypeInfo().Assembly);
+ TypeNameRegistry.Map(typeof(SchemaCreated).GetTypeInfo().Assembly);
services.AddSingleton(t => CreateSettings());
services.AddSingleton(t => CreateSerializer(t.GetRequiredService()));
diff --git a/src/PinkParrot/Configurations/WriteModule.cs b/src/PinkParrot/Configurations/WriteModule.cs
index 8d52481c5..30a08f683 100644
--- a/src/PinkParrot/Configurations/WriteModule.cs
+++ b/src/PinkParrot/Configurations/WriteModule.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// WriteDependencies.cs
+// WriteModule.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -9,7 +9,7 @@
using Autofac;
using PinkParrot.Infrastructure.CQRS.Commands;
using PinkParrot.Pipeline.CommandHandlers;
-using PinkParrot.Write.Schema;
+using PinkParrot.Write.Schemas;
namespace PinkParrot.Configurations
{
@@ -25,11 +25,11 @@ namespace PinkParrot.Configurations
.As()
.SingleInstance();
- builder.RegisterType()
+ builder.RegisterType()
.As()
.SingleInstance();
- builder.RegisterType()
+ builder.RegisterType()
.AsSelf()
.InstancePerDependency();
}
diff --git a/src/PinkParrot/Modules/Api/EntityCreatedDto.cs b/src/PinkParrot/Modules/Api/EntityCreatedDto.cs
index 5024425ad..98f714bff 100644
--- a/src/PinkParrot/Modules/Api/EntityCreatedDto.cs
+++ b/src/PinkParrot/Modules/Api/EntityCreatedDto.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// EntityCreated.cs
+// EntityCreatedDto.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
diff --git a/src/PinkParrot/Modules/Api/Schemas/CreateSchemaDto.cs b/src/PinkParrot/Modules/Api/Schemas/CreateSchemaDto.cs
index 5a4f1a4a0..13b32e241 100644
--- a/src/PinkParrot/Modules/Api/Schemas/CreateSchemaDto.cs
+++ b/src/PinkParrot/Modules/Api/Schemas/CreateSchemaDto.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// CreateFieldDto.cs
+// CreateSchemaDto.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -7,7 +7,7 @@
// ==========================================================================
using System.ComponentModel.DataAnnotations;
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
namespace PinkParrot.Modules.Api.Schemas
{
@@ -17,6 +17,6 @@ namespace PinkParrot.Modules.Api.Schemas
public string Name { get; set; }
[Required]
- public ModelFieldProperties Properties { get; set; }
+ public FieldProperties Properties { get; set; }
}
}
diff --git a/src/PinkParrot/Modules/Api/Schemas/ListSchemaDto.cs b/src/PinkParrot/Modules/Api/Schemas/ListSchemaDto.cs
index 1495ba5c8..8bbbb5ff2 100644
--- a/src/PinkParrot/Modules/Api/Schemas/ListSchemaDto.cs
+++ b/src/PinkParrot/Modules/Api/Schemas/ListSchemaDto.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// SchemaListModel.cs
+// ListSchemaDto.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
diff --git a/src/PinkParrot/Modules/Api/Schemas/SchemaFieldsController.cs b/src/PinkParrot/Modules/Api/Schemas/SchemaFieldsController.cs
index a9f4729f7..be171b58b 100644
--- a/src/PinkParrot/Modules/Api/Schemas/SchemaFieldsController.cs
+++ b/src/PinkParrot/Modules/Api/Schemas/SchemaFieldsController.cs
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using PinkParrot.Infrastructure.CQRS.Commands;
using PinkParrot.Infrastructure.Reflection;
-using PinkParrot.Write.Schema.Commands;
+using PinkParrot.Write.Schemas.Commands;
namespace PinkParrot.Modules.Api.Schemas
{
@@ -25,7 +25,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/fields/")]
public Task Add(string name, [FromBody] CreateFieldDto model)
{
- var command = SimpleMapper.Map(model, new AddModelField());
+ var command = SimpleMapper.Map(model, new AddField());
return CommandBus.PublishAsync(command);
}
@@ -34,7 +34,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/fields/{fieldId:long}/")]
public Task Update(string name, long fieldId, [FromBody] UpdateFieldDto model)
{
- var command = new UpdateModelField { FieldId = fieldId, Properties = model.Properties };
+ var command = new UpdateField { FieldId = fieldId, Properties = model.Properties };
return CommandBus.PublishAsync(command);
}
@@ -43,7 +43,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/fields/{fieldId:long}/hide/")]
public Task Hide(string name, long fieldId)
{
- var command = new HideModelField { FieldId = fieldId };
+ var command = new HideField { FieldId = fieldId };
return CommandBus.PublishAsync(command);
}
@@ -52,7 +52,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/fields/{fieldId:long}/show/")]
public Task Show(string name, long fieldId)
{
- var command = new ShowModelField { FieldId = fieldId };
+ var command = new ShowField { FieldId = fieldId };
return CommandBus.PublishAsync(command);
}
@@ -61,7 +61,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/fields/{fieldId:long}/enable/")]
public Task Enable(string name, long fieldId)
{
- var command = new EnableModelField { FieldId = fieldId };
+ var command = new EnableField { FieldId = fieldId };
return CommandBus.PublishAsync(command);
}
@@ -70,7 +70,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/fields/{fieldId:long}/disable/")]
public Task Disable(string name, long fieldId)
{
- var command = new DisableModelField { FieldId = fieldId };
+ var command = new DisableField { FieldId = fieldId };
return CommandBus.PublishAsync(command);
}
@@ -79,7 +79,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/fields/{fieldId:long}/")]
public Task Delete(string name, long fieldId)
{
- var command = new DeleteModelField { FieldId = fieldId };
+ var command = new DeleteField { FieldId = fieldId };
return CommandBus.PublishAsync(command);
}
diff --git a/src/PinkParrot/Modules/Api/Schemas/SchemasController.cs b/src/PinkParrot/Modules/Api/Schemas/SchemasController.cs
index e7814bab2..1baaa45b2 100644
--- a/src/PinkParrot/Modules/Api/Schemas/SchemasController.cs
+++ b/src/PinkParrot/Modules/Api/Schemas/SchemasController.cs
@@ -11,30 +11,30 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
using PinkParrot.Infrastructure.CQRS.Commands;
using PinkParrot.Infrastructure.Reflection;
using PinkParrot.Read.Models;
using PinkParrot.Read.Repositories;
-using PinkParrot.Write.Schema.Commands;
+using PinkParrot.Write.Schemas.Commands;
namespace PinkParrot.Modules.Api.Schemas
{
public class SchemasController : ControllerBase
{
- private readonly IModelSchemaRepository modelSchemaRepository;
+ private readonly ISchemaRepository schemaRepository;
- public SchemasController(ICommandBus commandBus, IModelSchemaRepository modelSchemaRepository)
+ public SchemasController(ICommandBus commandBus, ISchemaRepository schemaRepository)
: base(commandBus)
{
- this.modelSchemaRepository = modelSchemaRepository;
+ this.schemaRepository = schemaRepository;
}
[HttpGet]
[Route("api/schemas/")]
public async Task> Query()
{
- var schemas = await modelSchemaRepository.QueryAllAsync(TenantId);
+ var schemas = await schemaRepository.QueryAllAsync(TenantId);
return schemas.Select(s => SimpleMapper.Map(s, new ListSchemaDto())).ToList();
}
@@ -43,21 +43,21 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/")]
public async Task Get(string name)
{
- var entity = await modelSchemaRepository.FindSchemaAsync(TenantId, name);
+ var entity = await schemaRepository.FindSchemaAsync(TenantId, name);
if (entity == null)
{
return NotFound();
}
- return Ok(ModelSchemaDto.Create(entity.Schema));
+ return Ok(SchemaDto.Create(entity.Schema));
}
[HttpPost]
[Route("api/schemas/")]
public async Task Create([FromBody] CreateSchemaDto model)
{
- var command = SimpleMapper.Map(model, new CreateModelSchema { AggregateId = Guid.NewGuid() });
+ var command = SimpleMapper.Map(model, new CreateSchema { AggregateId = Guid.NewGuid() });
await CommandBus.PublishAsync(command);
@@ -66,9 +66,9 @@ namespace PinkParrot.Modules.Api.Schemas
[HttpPut]
[Route("api/schemas/{name}/")]
- public async Task Update(string name, [FromBody] ModelSchemaProperties schema)
+ public async Task Update(string name, [FromBody] SchemaProperties schema)
{
- var command = new UpdateModelSchema { Properties = schema };
+ var command = new UpdateSchema { Properties = schema };
await CommandBus.PublishAsync(command);
@@ -79,7 +79,7 @@ namespace PinkParrot.Modules.Api.Schemas
[Route("api/schemas/{name}/")]
public async Task Delete(string name)
{
- await CommandBus.PublishAsync(new DeleteModelSchema());
+ await CommandBus.PublishAsync(new DeleteSchema());
return NoContent();
}
diff --git a/src/PinkParrot/Pipeline/CommandHandlers/EnrichWithAggregateIdHandler.cs b/src/PinkParrot/Pipeline/CommandHandlers/EnrichWithAggregateIdHandler.cs
index c3c57be97..2d369051c 100644
--- a/src/PinkParrot/Pipeline/CommandHandlers/EnrichWithAggregateIdHandler.cs
+++ b/src/PinkParrot/Pipeline/CommandHandlers/EnrichWithAggregateIdHandler.cs
@@ -13,7 +13,7 @@ using PinkParrot.Infrastructure;
using PinkParrot.Infrastructure.CQRS.Commands;
using PinkParrot.Read.Services;
using PinkParrot.Write;
-using PinkParrot.Write.Schema;
+using PinkParrot.Write.Schemas;
// ReSharper disable InvertIf
@@ -21,12 +21,12 @@ namespace PinkParrot.Pipeline.CommandHandlers
{
public sealed class EnrichWithAggregateIdHandler : ICommandHandler
{
- private readonly IModelSchemaProvider modelSchemaProvider;
+ private readonly ISchemaProvider schemaProvider;
private readonly IActionContextAccessor actionContextAccessor;
- public EnrichWithAggregateIdHandler(IModelSchemaProvider modelSchemaProvider, IActionContextAccessor actionContextAccessor)
+ public EnrichWithAggregateIdHandler(ISchemaProvider schemaProvider, IActionContextAccessor actionContextAccessor)
{
- this.modelSchemaProvider = modelSchemaProvider;
+ this.schemaProvider = schemaProvider;
this.actionContextAccessor = actionContextAccessor;
}
@@ -53,11 +53,11 @@ namespace PinkParrot.Pipeline.CommandHandlers
{
var schemaName = routeValues["name"].ToString();
- var id = await modelSchemaProvider.FindSchemaIdByNameAsync(tenantCommand.TenantId, schemaName);
+ var id = await schemaProvider.FindSchemaIdByNameAsync(tenantCommand.TenantId, schemaName);
if (!id.HasValue)
{
- throw new DomainObjectNotFoundException(schemaName, typeof(ModelSchemaDomainObject));
+ throw new DomainObjectNotFoundException(schemaName, typeof(SchemaDomainObject));
}
aggregateCommand.AggregateId = id.Value;
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelField.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/Field.cs
similarity index 72%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/ModelField.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/Field.cs
index ad23f4a50..129b9d412 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelField.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/Field.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelField.cs
+// Field.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -15,9 +15,9 @@ using PinkParrot.Infrastructure.Tasks;
// ReSharper disable InvertIf
// ReSharper disable ConvertIfStatementToReturnStatement
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public abstract class ModelField
+ public abstract class Field
{
private readonly long id;
private string name;
@@ -44,7 +44,7 @@ namespace PinkParrot.Core.Schema
get { return isDisabled; }
}
- public abstract IModelFieldProperties RawProperties { get; }
+ public abstract IFieldProperties RawProperties { get; }
public abstract string Label { get; }
@@ -52,7 +52,7 @@ namespace PinkParrot.Core.Schema
public abstract bool IsRequired { get; }
- protected ModelField(long id, string name)
+ protected Field(long id, string name)
{
Guard.GreaterThan(id, 0, nameof(id));
Guard.ValidSlug(name, nameof(name));
@@ -62,7 +62,7 @@ namespace PinkParrot.Core.Schema
this.name = name;
}
- public abstract ModelField Update(IModelFieldProperties newProperties);
+ public abstract Field Update(IFieldProperties newProperties);
public Task ValidateAsync(PropertyValue property, ICollection errors)
{
@@ -86,27 +86,27 @@ namespace PinkParrot.Core.Schema
return TaskHelper.Done;
}
- public ModelField Hide()
+ public Field Hide()
{
- return Update(clone => clone.isHidden = true);
+ return Update(clone => clone.isHidden = true);
}
- public ModelField Show()
+ public Field Show()
{
- return Update(clone => clone.isHidden = false);
+ return Update(clone => clone.isHidden = false);
}
- public ModelField Disable()
+ public Field Disable()
{
- return Update(clone => clone.isDisabled = true);
+ return Update(clone => clone.isDisabled = true);
}
- public ModelField Enable()
+ public Field Enable()
{
- return Update(clone => clone.isDisabled = false);
+ return Update(clone => clone.isDisabled = false);
}
- public ModelField Rename(string newName)
+ public Field Rename(string newName)
{
if (!newName.IsSlug())
{
@@ -115,10 +115,10 @@ namespace PinkParrot.Core.Schema
throw new ValidationException($"Cannot rename the field '{name}' ({id})", error);
}
- return Update(clone => clone.name = newName);
+ return Update(clone => clone.name = newName);
}
- protected T Update(Action updater) where T : ModelField
+ protected T Update(Action updater) where T : Field
{
var clone = (T)Clone();
@@ -127,6 +127,6 @@ namespace PinkParrot.Core.Schema
return clone;
}
- protected abstract ModelField Clone();
+ protected abstract Field Clone();
}
}
\ No newline at end of file
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelFieldProperties.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/FieldProperties.cs
similarity index 75%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/ModelFieldProperties.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/FieldProperties.cs
index 6db47beb1..ee00d2ce4 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelFieldProperties.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/FieldProperties.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelFieldProperties.cs
+// FieldProperties.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -9,13 +9,13 @@
using System.Collections.Generic;
using PinkParrot.Infrastructure;
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public abstract class ModelFieldProperties : NamedElementProperties, IModelFieldProperties
+ public abstract class FieldProperties : NamedElementProperties, IFieldProperties
{
public bool IsRequired { get; }
- protected ModelFieldProperties(string label, string hints, bool isRequired)
+ protected FieldProperties(string label, string hints, bool isRequired)
: base(label, hints)
{
IsRequired = isRequired;
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelFieldRegistry.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/FieldRegistry.cs
similarity index 73%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/ModelFieldRegistry.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/FieldRegistry.cs
index 70935b3eb..f2756e4a9 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelFieldRegistry.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/FieldRegistry.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelFieldRegistry.cs
+// FieldRegistry.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -10,16 +10,16 @@ using System;
using System.Collections.Generic;
using PinkParrot.Infrastructure;
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public delegate ModelField FactoryFunction(long id, string name, IModelFieldProperties properties);
+ public delegate Field FactoryFunction(long id, string name, IFieldProperties properties);
- public sealed class ModelFieldRegistry
+ public sealed class FieldRegistry
{
- private readonly Dictionary fieldsByTypeName = new Dictionary();
- private readonly Dictionary fieldsByPropertyType = new Dictionary();
+ private readonly Dictionary fieldsByTypeName = new Dictionary();
+ private readonly Dictionary fieldsByPropertyType = new Dictionary();
- private sealed class Registered : IRegisterModelField
+ private sealed class Registered : IRegisteredField
{
private readonly FactoryFunction fieldFactory;
private readonly Type propertiesType;
@@ -43,13 +43,13 @@ namespace PinkParrot.Core.Schema
this.propertiesType = propertiesType;
}
- ModelField IRegisterModelField.CreateField(long id, string name, IModelFieldProperties properties)
+ Field IRegisteredField.CreateField(long id, string name, IFieldProperties properties)
{
return fieldFactory(id, name, properties);
}
}
- public ModelFieldRegistry()
+ public FieldRegistry()
{
Add((id, name, properties) => new NumberField(id, name, (NumberFieldProperties)properties));
}
@@ -64,14 +64,14 @@ namespace PinkParrot.Core.Schema
fieldsByPropertyType[registered.PropertiesType] = registered;
}
- public ModelField CreateField(long id, string name, IModelFieldProperties properties)
+ public Field CreateField(long id, string name, IFieldProperties properties)
{
var registered = fieldsByPropertyType[properties.GetType()];
return registered.CreateField(id, name, properties);
}
- public IRegisterModelField FindByPropertiesType(Type type)
+ public IRegisteredField FindByPropertiesType(Type type)
{
Guard.NotNull(type, nameof(type));
@@ -85,7 +85,7 @@ namespace PinkParrot.Core.Schema
return registered;
}
- public IRegisterModelField FindByTypeName(string typeName)
+ public IRegisteredField FindByTypeName(string typeName)
{
Guard.NotNullOrEmpty(typeName, nameof(typeName));
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelField_Generic.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/Field_Generic.cs
similarity index 77%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/ModelField_Generic.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/Field_Generic.cs
index f05a25b08..b1a1e0ab7 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelField_Generic.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/Field_Generic.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelField_Generic.cs
+// Field_Generic.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -9,13 +9,13 @@
using System;
using PinkParrot.Infrastructure;
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public abstract class ModelField : ModelField where T : ModelFieldProperties
+ public abstract class Field : Field where T : FieldProperties
{
private T properties;
- public override IModelFieldProperties RawProperties
+ public override IFieldProperties RawProperties
{
get { return properties; }
}
@@ -40,7 +40,7 @@ namespace PinkParrot.Core.Schema
get { return properties; }
}
- protected ModelField(long id, string name, T properties)
+ protected Field(long id, string name, T properties)
: base(id, name)
{
Guard.NotNull(properties, nameof(properties));
@@ -48,7 +48,7 @@ namespace PinkParrot.Core.Schema
this.properties = properties;
}
- public override ModelField Update(IModelFieldProperties newProperties)
+ public override Field Update(IFieldProperties newProperties)
{
Guard.NotNull(newProperties, nameof(newProperties));
@@ -61,7 +61,7 @@ namespace PinkParrot.Core.Schema
newProperties.Validate(() => $"Cannot update field with id '{Id}', becase the settings are invalid.");
- return Update>(clone => clone.properties = typedProperties);
+ return Update>(clone => clone.properties = typedProperties);
}
}
}
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/IModelFieldProperties.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/IFieldProperties.cs
similarity index 75%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/IModelFieldProperties.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/IFieldProperties.cs
index a011a0bae..4855988a6 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/IModelFieldProperties.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/IFieldProperties.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// IModelFieldProperties.cs
+// IFieldProperties.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,9 +8,9 @@
using PinkParrot.Infrastructure;
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public interface IModelFieldProperties : IValidatable
+ public interface IFieldProperties : IValidatable
{
}
}
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/IRegisterModelField.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/IRegisteredField.cs
similarity index 67%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/IRegisterModelField.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/IRegisteredField.cs
index bfff4f862..78cf8ca40 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/IRegisterModelField.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/IRegisteredField.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// IRegisterModelField.cs
+// IRegisteredField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,12 +8,12 @@
using System;
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public interface IRegisterModelField
+ public interface IRegisteredField
{
Type PropertiesType { get; }
- ModelField CreateField(long id, string name, IModelFieldProperties properties);
+ Field CreateField(long id, string name, IFieldProperties properties);
}
}
\ No newline at end of file
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/NamedElementProperties.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/NamedElementProperties.cs
similarity index 95%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/NamedElementProperties.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/NamedElementProperties.cs
index cdfce8f45..bf2b1659c 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/NamedElementProperties.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/NamedElementProperties.cs
@@ -5,8 +5,7 @@
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
public abstract class NamedElementProperties
{
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/NumberField.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/NumberField.cs
similarity index 90%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/NumberField.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/NumberField.cs
index f7e826ebb..c52b00c9f 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/NumberField.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/NumberField.cs
@@ -14,9 +14,9 @@ using System.Threading.Tasks;
using PinkParrot.Infrastructure;
using PinkParrot.Infrastructure.Tasks;
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public sealed class NumberField : ModelField
+ public sealed class NumberField : Field
{
public double? MaxValue
{
@@ -67,9 +67,9 @@ namespace PinkParrot.Core.Schema
return TaskHelper.Done;
}
- protected override ModelField Clone()
+ protected override Field Clone()
{
- return (ModelField)MemberwiseClone();
+ return (Field)MemberwiseClone();
}
}
}
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/NumberFieldProperties.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/NumberFieldProperties.cs
similarity index 95%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/NumberFieldProperties.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/NumberFieldProperties.cs
index d1d3efc7b..44bf27acd 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/NumberFieldProperties.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/NumberFieldProperties.cs
@@ -9,10 +9,10 @@
using System.Collections.Generic;
using PinkParrot.Infrastructure;
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
[TypeName("number")]
- public sealed class NumberFieldProperties : ModelFieldProperties
+ public sealed class NumberFieldProperties : FieldProperties
{
public string Placeholder { get; set; }
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelSchema.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/Schema.cs
similarity index 64%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/ModelSchema.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/Schema.cs
index 0679b3022..5ce45e5dd 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelSchema.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/Schema.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelSchema.cs
+// Schema.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -12,33 +12,34 @@ using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using PinkParrot.Infrastructure;
+
// ReSharper disable InvertIf
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public sealed class ModelSchema
+ public sealed class Schema
{
private readonly string name;
- private readonly ModelSchemaProperties properties;
- private readonly ImmutableDictionary fieldsById;
- private readonly Dictionary fieldsByName;
+ private readonly SchemaProperties properties;
+ private readonly ImmutableDictionary fieldsById;
+ private readonly Dictionary fieldsByName;
public string Name
{
get { return name; }
}
- public ImmutableDictionary Fields
+ public ImmutableDictionary Fields
{
get { return fieldsById; }
}
- public ModelSchemaProperties Properties
+ public SchemaProperties Properties
{
get { return properties; }
}
- public ModelSchema(string name, ModelSchemaProperties properties, ImmutableDictionary fields)
+ public Schema(string name, SchemaProperties properties, ImmutableDictionary fields)
{
Guard.NotNull(fields, nameof(fields));
Guard.NotNull(properties, nameof(properties));
@@ -52,28 +53,28 @@ namespace PinkParrot.Core.Schema
fieldsByName = fields.Values.ToDictionary(x => x.Name, StringComparer.OrdinalIgnoreCase);
}
- public static ModelSchema Create(string name, ModelSchemaProperties newProperties)
+ public static Schema Create(string name, SchemaProperties newProperties)
{
- newProperties = newProperties ?? new ModelSchemaProperties(null, null);
+ newProperties = newProperties ?? new SchemaProperties(null, null);
if (!name.IsSlug())
{
var error = new ValidationError("Name must be a valid slug", "Name");
- throw new ValidationException($"Cannot create a new schema", error);
+ throw new ValidationException("Cannot create a new schema", error);
}
- return new ModelSchema(name, newProperties, ImmutableDictionary.Empty);
+ return new Schema(name, newProperties, ImmutableDictionary.Empty);
}
- public ModelSchema Update(ModelSchemaProperties newProperties)
+ public Schema Update(SchemaProperties newProperties)
{
Guard.NotNull(newProperties, nameof(newProperties));
- return new ModelSchema(name, newProperties, fieldsById);
+ return new Schema(name, newProperties, fieldsById);
}
- public ModelSchema AddOrUpdateField(ModelField field)
+ public Schema AddOrUpdateField(Field field)
{
Guard.NotNull(field, nameof(field));
@@ -82,53 +83,53 @@ namespace PinkParrot.Core.Schema
throw new ValidationException($"A field with name '{field.Name}' already exists.");
}
- return new ModelSchema(name, properties, fieldsById.SetItem(field.Id, field));
+ return new Schema(name, properties, fieldsById.SetItem(field.Id, field));
}
- public ModelSchema UpdateField(long fieldId, IModelFieldProperties newProperties)
+ public Schema UpdateField(long fieldId, IFieldProperties newProperties)
{
return UpdateField(fieldId, field => field.Update(newProperties));
}
- public ModelSchema DisableField(long fieldId)
+ public Schema DisableField(long fieldId)
{
return UpdateField(fieldId, field => field.Disable());
}
- public ModelSchema EnableField(long fieldId)
+ public Schema EnableField(long fieldId)
{
return UpdateField(fieldId, field => field.Enable());
}
- public ModelSchema HideField(long fieldId)
+ public Schema HideField(long fieldId)
{
return UpdateField(fieldId, field => field.Show());
}
- public ModelSchema ShowField(long fieldId)
+ public Schema ShowField(long fieldId)
{
return UpdateField(fieldId, field => field.Show());
}
- public ModelSchema RenameField(long fieldId, string newName)
+ public Schema RenameField(long fieldId, string newName)
{
return UpdateField(fieldId, field => field.Rename(newName));
}
- public ModelSchema DeleteField(long fieldId)
+ public Schema DeleteField(long fieldId)
{
- return new ModelSchema(name, properties, fieldsById.Remove(fieldId));
+ return new Schema(name, properties, fieldsById.Remove(fieldId));
}
- public ModelSchema UpdateField(long fieldId, Func updater)
+ public Schema UpdateField(long fieldId, Func updater)
{
Guard.NotNull(updater, nameof(updater));
- ModelField field;
+ Field field;
if (!fieldsById.TryGetValue(fieldId, out field))
{
- throw new DomainObjectNotFoundException(fieldId.ToString(), typeof(ModelField));
+ throw new DomainObjectNotFoundException(fieldId.ToString(), typeof(Field));
}
var newField = updater(field);
@@ -145,7 +146,7 @@ namespace PinkParrot.Core.Schema
{
var fieldErrors = new List();
- ModelField field;
+ Field field;
if (fieldsByName.TryGetValue(kvp.Key, out field))
{
diff --git a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelSchemaProperties.cs b/src/pinkparrot_core/PinkParrot.Core/Schemas/SchemaProperties.cs
similarity index 71%
rename from src/pinkparrot_core/PinkParrot.Core/Schema/ModelSchemaProperties.cs
rename to src/pinkparrot_core/PinkParrot.Core/Schemas/SchemaProperties.cs
index a651dc86e..4ff4e0da9 100644
--- a/src/pinkparrot_core/PinkParrot.Core/Schema/ModelSchemaProperties.cs
+++ b/src/pinkparrot_core/PinkParrot.Core/Schemas/SchemaProperties.cs
@@ -1,15 +1,15 @@
// ==========================================================================
-// ModelSchemaProperties.cs
+// SchemaProperties.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-namespace PinkParrot.Core.Schema
+namespace PinkParrot.Core.Schemas
{
- public sealed class ModelSchemaProperties : NamedElementProperties
+ public sealed class SchemaProperties : NamedElementProperties
{
- public ModelSchemaProperties(
+ public SchemaProperties(
string label,
string hints)
: base(label, hints)
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldUpdated.cs b/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldUpdated.cs
deleted file mode 100644
index 518293ce0..000000000
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldUpdated.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// ==========================================================================
-// ModelFieldUpdated.cs
-// PinkParrot Headless CMS
-// ==========================================================================
-// Copyright (c) PinkParrot Group
-// All rights reserved.
-// ==========================================================================
-
-using PinkParrot.Core.Schema;
-using PinkParrot.Infrastructure;
-
-namespace PinkParrot.Events.Schema
-{
- [TypeName("ModelFieldUpdatedEvent")]
- public class ModelFieldUpdated : TenantEvent
- {
- public long FieldId { get; set; }
-
- public IModelFieldProperties Properties { get; set; }
- }
-}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaUpdated.cs b/src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaUpdated.cs
deleted file mode 100644
index b82717fbc..000000000
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaUpdated.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// ==========================================================================
-// ModelSchemaUpdated.cs
-// PinkParrot Headless CMS
-// ==========================================================================
-// Copyright (c) PinkParrot Group
-// All rights reserved.
-// ==========================================================================
-
-using PinkParrot.Core.Schema;
-using PinkParrot.Infrastructure;
-
-namespace PinkParrot.Events.Schema
-{
- [TypeName("ModelSchemaUpdated")]
- public class ModelSchemaUpdated : TenantEvent
- {
- public ModelSchemaProperties Properties { get; set; }
- }
-}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldAdded.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldAdded.cs
similarity index 66%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldAdded.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/FieldAdded.cs
index 7709bb3ba..5dd9d7afe 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldAdded.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldAdded.cs
@@ -1,23 +1,23 @@
// ==========================================================================
-// ModelFieldAdded.cs
+// FieldAdded.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelFieldAddedEvent")]
- public class ModelFieldAdded : TenantEvent
+ [TypeName("FieldAddedEvent")]
+ public class FieldAdded : TenantEvent
{
public long FieldId { get; set; }
public string Name { get; set; }
- public IModelFieldProperties Properties { get; set; }
+ public IFieldProperties Properties { get; set; }
}
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldShown.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldDeleted.cs
similarity index 74%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldShown.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/FieldDeleted.cs
index fba7d467a..431f7915e 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldShown.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldDeleted.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelFieldShown.cs
+// FieldDeleted.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,10 +8,10 @@
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelFieldShownEvent")]
- public class ModelFieldShown : TenantEvent
+ [TypeName("FieldDeletedEvent")]
+ public class FieldDeleted : TenantEvent
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldHidden.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldDisabled.cs
similarity index 73%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldHidden.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/FieldDisabled.cs
index 2e4a558d2..de1698c9b 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldHidden.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldDisabled.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelFieldHidden.cs
+// FieldDisabled.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,10 +8,10 @@
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelFieldHiddenEvent")]
- public class ModelFieldHidden : TenantEvent
+ [TypeName("FieldDisabledEvent")]
+ public class FieldDisabled : TenantEvent
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldDeleted.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldEnabled.cs
similarity index 73%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldDeleted.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/FieldEnabled.cs
index 59da03c86..2bc088b54 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldDeleted.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldEnabled.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelFieldDeleted.cs
+// FieldEnabled.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,10 +8,10 @@
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelFieldDeletedEvent")]
- public class ModelFieldDeleted : TenantEvent
+ [TypeName("FieldEnabledEvent")]
+ public class FieldEnabled : TenantEvent
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldEnabled.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldHidden.cs
similarity index 73%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldEnabled.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/FieldHidden.cs
index 36d8a96fe..6c3b62666 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldEnabled.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldHidden.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelFieldEnabled.cs
+// FieldHidden.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,10 +8,10 @@
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelFieldEnabledEvent")]
- public class ModelFieldEnabled : TenantEvent
+ [TypeName("FieldHiddenEvent")]
+ public class FieldHidden : TenantEvent
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldShown.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldShown.cs
new file mode 100644
index 000000000..668c71f81
--- /dev/null
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldShown.cs
@@ -0,0 +1,18 @@
+// ==========================================================================
+// FieldShown.cs
+// PinkParrot Headless CMS
+// ==========================================================================
+// Copyright (c) PinkParrot Group
+// All rights reserved.
+// ==========================================================================
+
+using PinkParrot.Infrastructure;
+
+namespace PinkParrot.Events.Schemas
+{
+ [TypeName("FieldShownEvent")]
+ public class FieldShown : TenantEvent
+ {
+ public long FieldId { get; set; }
+ }
+}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldDisabled.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldUpdated.cs
similarity index 65%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldDisabled.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/FieldUpdated.cs
index 090829e7e..e857ecc28 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelFieldDisabled.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/FieldUpdated.cs
@@ -1,18 +1,21 @@
// ==========================================================================
-// ModelFieldDisabled.cs
+// FieldUpdated.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
+using PinkParrot.Core.Schemas;
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelFieldDisabledEvent")]
- public class ModelFieldDisabled : TenantEvent
+ [TypeName("FieldUpdatedEvent")]
+ public class FieldUpdated : TenantEvent
{
public long FieldId { get; set; }
+
+ public IFieldProperties Properties { get; set; }
}
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaCreated.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaCreated.cs
similarity index 62%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaCreated.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaCreated.cs
index 88b1c329f..cca321c77 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaCreated.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaCreated.cs
@@ -1,21 +1,21 @@
// ==========================================================================
-// ModelSchemaCreated.cs
+// SchemaCreated.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelSchemaCreatedEvent")]
- public class ModelSchemaCreated : TenantEvent
+ [TypeName("SchemaCreatedEvent")]
+ public class SchemaCreated : TenantEvent
{
public string Name { get; set; }
- public ModelSchemaProperties Properties { get; set; }
+ public SchemaProperties Properties { get; set; }
}
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaDeleted.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaDeleted.cs
similarity index 71%
rename from src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaDeleted.cs
rename to src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaDeleted.cs
index 6c11384a6..3d05a1f77 100644
--- a/src/pinkparrot_events/PinkParrot.Events/Schema/ModelSchemaDeleted.cs
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaDeleted.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelSchemaDeleted.cs
+// SchemaDeleted.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,10 +8,10 @@
using PinkParrot.Infrastructure;
-namespace PinkParrot.Events.Schema
+namespace PinkParrot.Events.Schemas
{
- [TypeName("ModelSchemaDeleted")]
- public class ModelSchemaDeleted : TenantEvent
+ [TypeName("SchemaDeleted")]
+ public class SchemaDeleted : TenantEvent
{
}
}
diff --git a/src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaUpdated.cs b/src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaUpdated.cs
new file mode 100644
index 000000000..4651a7e60
--- /dev/null
+++ b/src/pinkparrot_events/PinkParrot.Events/Schemas/SchemaUpdated.cs
@@ -0,0 +1,19 @@
+// ==========================================================================
+// SchemaUpdated.cs
+// PinkParrot Headless CMS
+// ==========================================================================
+// Copyright (c) PinkParrot Group
+// All rights reserved.
+// ==========================================================================
+
+using PinkParrot.Core.Schemas;
+using PinkParrot.Infrastructure;
+
+namespace PinkParrot.Events.Schemas
+{
+ [TypeName("SchemaUpdated")]
+ public class SchemaUpdated : TenantEvent
+ {
+ public SchemaProperties Properties { get; set; }
+ }
+}
diff --git a/src/pinkparrot_infrastructure/PinkParrot.Infrastructure/CQRS/EventStore/IStreamPositionStorage.cs b/src/pinkparrot_infrastructure/PinkParrot.Infrastructure/CQRS/EventStore/IStreamPositionStorage.cs
index c039801ab..4cfdabdfe 100644
--- a/src/pinkparrot_infrastructure/PinkParrot.Infrastructure/CQRS/EventStore/IStreamPositionStorage.cs
+++ b/src/pinkparrot_infrastructure/PinkParrot.Infrastructure/CQRS/EventStore/IStreamPositionStorage.cs
@@ -5,7 +5,6 @@
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
namespace PinkParrot.Infrastructure.CQRS.EventStore
{
public interface IStreamPositionStorage
diff --git a/src/pinkparrot_read/PinkParrot.Read/Models/ModelFieldDto.cs b/src/pinkparrot_read/PinkParrot.Read/Models/FieldDto.cs
similarity index 62%
rename from src/pinkparrot_read/PinkParrot.Read/Models/ModelFieldDto.cs
rename to src/pinkparrot_read/PinkParrot.Read/Models/FieldDto.cs
index 7bb4088ad..f04ded3ed 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Models/ModelFieldDto.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Models/FieldDto.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelFieldDto.cs
+// FieldDto.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -7,21 +7,21 @@
// ==========================================================================
using Newtonsoft.Json;
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
namespace PinkParrot.Read.Models
{
- public class ModelFieldDto
+ public class FieldDto
{
[JsonProperty]
public string Name { get; set; }
[JsonProperty]
- public IModelFieldProperties Properties { get; set; }
+ public IFieldProperties Properties { get; set; }
- public static ModelFieldDto Create(ModelField field)
+ public static FieldDto Create(Field field)
{
- return new ModelFieldDto { Name = field.Name, Properties = field.RawProperties };
+ return new FieldDto { Name = field.Name, Properties = field.RawProperties };
}
}
}
\ No newline at end of file
diff --git a/src/pinkparrot_read/PinkParrot.Read/Models/ModelSchemaDto.cs b/src/pinkparrot_read/PinkParrot.Read/Models/SchemaDto.cs
similarity index 69%
rename from src/pinkparrot_read/PinkParrot.Read/Models/ModelSchemaDto.cs
rename to src/pinkparrot_read/PinkParrot.Read/Models/SchemaDto.cs
index 7ed58811c..c06edd658 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Models/ModelSchemaDto.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Models/SchemaDto.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelSchemaDto.cs
+// SchemaDto.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,44 +8,45 @@
using System.Collections.Generic;
using System.Linq;
-using PinkParrot.Core.Schema;
-using PinkParrot.Infrastructure;
using Newtonsoft.Json;
+using PinkParrot.Core.Schemas;
+using PinkParrot.Infrastructure;
+
// ReSharper disable UseObjectOrCollectionInitializer
// ReSharper disable InvertIf
namespace PinkParrot.Read.Models
{
- public sealed class ModelSchemaDto
+ public sealed class SchemaDto
{
[JsonProperty]
public string Name { get; set; }
[JsonProperty]
- public Dictionary Fields { get; set; }
+ public Dictionary Fields { get; set; }
[JsonProperty]
- public ModelSchemaProperties Properties { get; set; }
+ public SchemaProperties Properties { get; set; }
- public static ModelSchemaDto Create(ModelSchema schema)
+ public static SchemaDto Create(Schema schema)
{
Guard.NotNull(schema, nameof(schema));
- var dto = new ModelSchemaDto { Properties = schema.Properties, Name = schema.Name };
+ var dto = new SchemaDto { Properties = schema.Properties, Name = schema.Name };
dto.Fields =
schema.Fields.ToDictionary(
kvp => kvp.Key,
- kvp => ModelFieldDto.Create(kvp.Value));
+ kvp => FieldDto.Create(kvp.Value));
return dto;
}
- public ModelSchema ToSchema(ModelFieldRegistry registry)
+ public Schema ToSchema(FieldRegistry registry)
{
Guard.NotNull(registry, nameof(registry));
- var schema = ModelSchema.Create(Name, Properties);
+ var schema = Schema.Create(Name, Properties);
if (Fields != null)
{
diff --git a/src/pinkparrot_read/PinkParrot.Read/Repositories/EntityWithSchema.cs b/src/pinkparrot_read/PinkParrot.Read/Repositories/EntityWithSchema.cs
index 8abc989fb..603698076 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Repositories/EntityWithSchema.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Repositories/EntityWithSchema.cs
@@ -6,17 +6,17 @@
// All rights reserved.
// ==========================================================================
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
namespace PinkParrot.Read.Repositories
{
public sealed class EntityWithSchema
{
- public IModelSchemaEntity Entity { get; }
+ public ISchemaEntity Entity { get; }
- public ModelSchema Schema { get; }
+ public Schema Schema { get; }
- internal EntityWithSchema(IModelSchemaEntity entity, ModelSchema schema)
+ internal EntityWithSchema(ISchemaEntity entity, Schema schema)
{
Entity = entity;
diff --git a/src/pinkparrot_read/PinkParrot.Read/Repositories/IModelSchemaEntity.cs b/src/pinkparrot_read/PinkParrot.Read/Repositories/ISchemaEntity.cs
similarity index 83%
rename from src/pinkparrot_read/PinkParrot.Read/Repositories/IModelSchemaEntity.cs
rename to src/pinkparrot_read/PinkParrot.Read/Repositories/ISchemaEntity.cs
index 7744afc10..0ac8231f5 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Repositories/IModelSchemaEntity.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Repositories/ISchemaEntity.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// IModelSchemaEntity.cs
+// ISchemaEntity.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -7,7 +7,7 @@
// ==========================================================================
namespace PinkParrot.Read.Repositories
{
- public interface IModelSchemaEntity : ITenantEntity
+ public interface ISchemaEntity : ITenantEntity
{
string Name { get; }
}
diff --git a/src/pinkparrot_read/PinkParrot.Read/Repositories/IModelSchemaRepository.cs b/src/pinkparrot_read/PinkParrot.Read/Repositories/ISchemaRepository.cs
similarity index 82%
rename from src/pinkparrot_read/PinkParrot.Read/Repositories/IModelSchemaRepository.cs
rename to src/pinkparrot_read/PinkParrot.Read/Repositories/ISchemaRepository.cs
index a485d4249..853be2a25 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Repositories/IModelSchemaRepository.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Repositories/ISchemaRepository.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// IModelSchemaRepository.cs
+// ISchemaRepository.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -12,9 +12,9 @@ using System.Threading.Tasks;
namespace PinkParrot.Read.Repositories
{
- public interface IModelSchemaRepository
+ public interface ISchemaRepository
{
- Task> QueryAllAsync(Guid tenantId);
+ Task> QueryAllAsync(Guid tenantId);
Task FindSchemaIdAsync(Guid tenantId, string name);
diff --git a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPositions.cs b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPosition.cs
similarity index 96%
rename from src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPositions.cs
rename to src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPosition.cs
index 3c6119843..1b5d41df1 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPositions.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPosition.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// MongoPositions.cs
+// MongoPosition.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
diff --git a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoStreamPositionsStorage.cs b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPositionStorage.cs
similarity index 84%
rename from src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoStreamPositionsStorage.cs
rename to src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPositionStorage.cs
index a04b43b4e..3da6baf00 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoStreamPositionsStorage.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoPositionStorage.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// MongoStreamPositionsStorage.cs
+// MongoPositionStorage.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -15,11 +15,11 @@ using PinkParrot.Infrastructure.MongoDb;
namespace PinkParrot.Read.Repositories.Implementations.Mongo
{
- public sealed class MongoStreamPositionsStorage : MongoRepositoryBase, IStreamPositionStorage
+ public sealed class MongoPositionStorage : MongoRepositoryBase, IStreamPositionStorage
{
private static readonly ObjectId Id = new ObjectId("507f1f77bcf86cd799439011");
- public MongoStreamPositionsStorage(IMongoDatabase database)
+ public MongoPositionStorage(IMongoDatabase database)
: base(database)
{
}
diff --git a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoModelSchemaEntity.cs b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoSchemaEntity.cs
similarity index 92%
rename from src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoModelSchemaEntity.cs
rename to src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoSchemaEntity.cs
index 13df3bf46..6c4b39698 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoModelSchemaEntity.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoSchemaEntity.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// MongoModelSchemaEntity.cs
+// MongoSchemaEntity.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -12,7 +12,7 @@ using MongoDB.Bson.Serialization.Attributes;
namespace PinkParrot.Read.Repositories.Implementations.Mongo
{
- public sealed class MongoModelSchemaEntity : IModelSchemaEntity
+ public sealed class MongoSchemaEntity : ISchemaEntity
{
[BsonId]
[BsonElement]
diff --git a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoModelSchemaRepository.cs b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoSchemaRepository.cs
similarity index 67%
rename from src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoModelSchemaRepository.cs
rename to src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoSchemaRepository.cs
index f4c1e2be4..660ab7638 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoModelSchemaRepository.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Repositories/Implementations/Mongo/MongoSchemaRepository.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// MongoModelSchemaRepository.cs
+// MongoSchemaRepository.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -12,8 +12,8 @@ using System.Linq;
using System.Threading.Tasks;
using MongoDB.Driver;
using Newtonsoft.Json;
-using PinkParrot.Core.Schema;
-using PinkParrot.Events.Schema;
+using PinkParrot.Core.Schemas;
+using PinkParrot.Events.Schemas;
using PinkParrot.Infrastructure;
using PinkParrot.Infrastructure.CQRS;
using PinkParrot.Infrastructure.CQRS.Events;
@@ -23,12 +23,12 @@ using PinkParrot.Read.Models;
namespace PinkParrot.Read.Repositories.Implementations.Mongo
{
- public sealed class MongoModelSchemaRepository : MongoRepositoryBase, IModelSchemaRepository, ICatchEventConsumer
+ public sealed class MongoSchemaRepository : MongoRepositoryBase, ISchemaRepository, ICatchEventConsumer
{
private readonly JsonSerializerSettings serializerSettings;
- private readonly ModelFieldRegistry fieldRegistry;
+ private readonly FieldRegistry fieldRegistry;
- public MongoModelSchemaRepository(IMongoDatabase database, JsonSerializerSettings serializerSettings, ModelFieldRegistry fieldRegistry)
+ public MongoSchemaRepository(IMongoDatabase database, JsonSerializerSettings serializerSettings, FieldRegistry fieldRegistry)
: base(database)
{
Guard.NotNull(serializerSettings, nameof(serializerSettings));
@@ -38,16 +38,16 @@ namespace PinkParrot.Read.Repositories.Implementations.Mongo
this.fieldRegistry = fieldRegistry;
}
- protected override Task SetupCollectionAsync(IMongoCollection collection)
+ protected override Task SetupCollectionAsync(IMongoCollection collection)
{
return collection.Indexes.CreateOneAsync(IndexKeys.Ascending(x => x.Name));
}
- public async Task> QueryAllAsync(Guid tenantId)
+ public async Task> QueryAllAsync(Guid tenantId)
{
var entities = await Collection.Find(s => s.TenantId == tenantId && !s.IsDeleted).ToListAsync();
- return entities.OfType().ToList();
+ return entities.OfType().ToList();
}
public async Task FindSchemaAsync(Guid tenantId, string name)
@@ -72,65 +72,65 @@ namespace PinkParrot.Read.Repositories.Implementations.Mongo
{
var entity =
await Collection.Find(s => s.Name == name & s.TenantId == tenantId && !s.IsDeleted)
- .Project(Projection.Include(x => x.Id)).FirstOrDefaultAsync();
+ .Project(Projection.Include(x => x.Id)).FirstOrDefaultAsync();
return entity?.Id;
}
- public Task On(ModelSchemaDeleted @event, EnvelopeHeaders headers)
+ public Task On(SchemaDeleted @event, EnvelopeHeaders headers)
{
return Collection.UpdateAsync(headers, e => e.IsDeleted = true);
}
- public Task On(ModelFieldDeleted @event, EnvelopeHeaders headers)
+ public Task On(FieldDeleted @event, EnvelopeHeaders headers)
{
return UpdateSchema(headers, s => s.DeleteField(@event.FieldId));
}
- public Task On(ModelFieldDisabled @event, EnvelopeHeaders headers)
+ public Task On(FieldDisabled @event, EnvelopeHeaders headers)
{
return UpdateSchema(headers, s => s.DisableField(@event.FieldId));
}
- public Task On(ModelFieldEnabled @event, EnvelopeHeaders headers)
+ public Task On(FieldEnabled @event, EnvelopeHeaders headers)
{
return UpdateSchema(headers, s => s.EnableField(@event.FieldId));
}
- public Task On(ModelFieldHidden @event, EnvelopeHeaders headers)
+ public Task On(FieldHidden @event, EnvelopeHeaders headers)
{
return UpdateSchema(headers, s => s.HideField(@event.FieldId));
}
- public Task On(ModelFieldShown @event, EnvelopeHeaders headers)
+ public Task On(FieldShown @event, EnvelopeHeaders headers)
{
return UpdateSchema(headers, s => s.ShowField(@event.FieldId));
}
- public Task On(ModelFieldUpdated @event, EnvelopeHeaders headers)
+ public Task On(FieldUpdated @event, EnvelopeHeaders headers)
{
return UpdateSchema(headers, s => s.UpdateField(@event.FieldId, @event.Properties));
}
- public Task On(ModelSchemaUpdated @event, EnvelopeHeaders headers)
+ public Task On(SchemaUpdated @event, EnvelopeHeaders headers)
{
return UpdateSchema(headers, s => s.Update(@event.Properties));
}
- public Task On(ModelFieldAdded @event, EnvelopeHeaders headers)
+ public Task On(FieldAdded @event, EnvelopeHeaders headers)
{
var field = fieldRegistry.CreateField(@event.FieldId, @event.Name, @event.Properties);
return UpdateSchema(headers, s => s.AddOrUpdateField(field));
}
- public Task On(ModelSchemaCreated @event, EnvelopeHeaders headers)
+ public Task On(SchemaCreated @event, EnvelopeHeaders headers)
{
return Collection.CreateAsync(headers, e =>
{
e.Name = @event.Name;
- Serialize(e, ModelSchema.Create(@event.Name, @event.Properties));
+ Serialize(e, Schema.Create(@event.Name, @event.Properties));
});
}
@@ -139,7 +139,7 @@ namespace PinkParrot.Read.Repositories.Implementations.Mongo
return this.DispatchActionAsync(@event.Payload, @event.Headers);
}
- private void UpdateSchema(MongoModelSchemaEntity entity, Func updater)
+ private void UpdateSchema(MongoSchemaEntity entity, Func updater)
{
var currentSchema = Deserialize(entity);
@@ -148,21 +148,21 @@ namespace PinkParrot.Read.Repositories.Implementations.Mongo
Serialize(entity, currentSchema);
}
- private Task UpdateSchema(EnvelopeHeaders headers, Func updater)
+ private Task UpdateSchema(EnvelopeHeaders headers, Func updater)
{
return Collection.UpdateAsync(headers, e=> UpdateSchema(e, updater));
}
- private void Serialize(MongoModelSchemaEntity entity, ModelSchema schema)
+ private void Serialize(MongoSchemaEntity entity, Schema schema)
{
- var dto = ModelSchemaDto.Create(schema);
+ var dto = SchemaDto.Create(schema);
entity.Schema = dto.ToJsonBsonDocument(serializerSettings);
}
- private ModelSchema Deserialize(MongoModelSchemaEntity entity)
+ private Schema Deserialize(MongoSchemaEntity entity)
{
- var dto = entity?.Schema.ToJsonObject(serializerSettings);
+ var dto = entity?.Schema.ToJsonObject(serializerSettings);
return dto?.ToSchema(fieldRegistry);
}
diff --git a/src/pinkparrot_read/PinkParrot.Read/Services/IModelSchemaProvider.cs b/src/pinkparrot_read/PinkParrot.Read/Services/ISchemaProvider.cs
similarity index 87%
rename from src/pinkparrot_read/PinkParrot.Read/Services/IModelSchemaProvider.cs
rename to src/pinkparrot_read/PinkParrot.Read/Services/ISchemaProvider.cs
index 6480eadee..eac10cb9a 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Services/IModelSchemaProvider.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Services/ISchemaProvider.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// IModelSchemaProvider.cs
+// ISchemaProvider.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace PinkParrot.Read.Services
{
- public interface IModelSchemaProvider
+ public interface ISchemaProvider
{
Task FindSchemaIdByNameAsync(Guid tenantId, string name);
}
diff --git a/src/pinkparrot_read/PinkParrot.Read/Services/Implementations/ModelSchemaProvider.cs b/src/pinkparrot_read/PinkParrot.Read/Services/Implementations/CachingSchemaProvider.cs
similarity index 86%
rename from src/pinkparrot_read/PinkParrot.Read/Services/Implementations/ModelSchemaProvider.cs
rename to src/pinkparrot_read/PinkParrot.Read/Services/Implementations/CachingSchemaProvider.cs
index 66f8fa1b1..d2d00b58e 100644
--- a/src/pinkparrot_read/PinkParrot.Read/Services/Implementations/ModelSchemaProvider.cs
+++ b/src/pinkparrot_read/PinkParrot.Read/Services/Implementations/CachingSchemaProvider.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelSchemaProvider.cs
+// CachingSchemaProvider.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -9,22 +9,23 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
-using PinkParrot.Events.Schema;
+using PinkParrot.Events.Schemas;
using PinkParrot.Infrastructure;
using PinkParrot.Infrastructure.CQRS;
using PinkParrot.Infrastructure.CQRS.Events;
using PinkParrot.Read.Repositories;
+
// ReSharper disable InvertIf
namespace PinkParrot.Read.Services.Implementations
{
- public class ModelSchemaProvider : IModelSchemaProvider, ILiveEventConsumer
+ public class CachingSchemaProvider : ISchemaProvider, ILiveEventConsumer
{
private static readonly TimeSpan CacheDuration = TimeSpan.FromMinutes(10);
private readonly IMemoryCache cache;
- private readonly IModelSchemaRepository repository;
+ private readonly ISchemaRepository repository;
- public ModelSchemaProvider(IMemoryCache cache, IModelSchemaRepository repository)
+ public CachingSchemaProvider(IMemoryCache cache, ISchemaRepository repository)
{
Guard.NotNull(cache, nameof(cache));
Guard.NotNull(repository, nameof(repository));
@@ -58,7 +59,7 @@ namespace PinkParrot.Read.Services.Implementations
public Task On(Envelope @event)
{
- if (@event.Payload is ModelSchemaUpdated || @event.Payload is ModelSchemaDeleted)
+ if (@event.Payload is SchemaUpdated || @event.Payload is SchemaDeleted)
{
var oldName = cache.Get(BuildNamesCacheKey(@event.Headers.AggregateId()));
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/UpdateModelSchema.cs b/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/UpdateModelSchema.cs
deleted file mode 100644
index e67c4c394..000000000
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/UpdateModelSchema.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// ==========================================================================
-// UpdateModelSchema.cs
-// PinkParrot Headless CMS
-// ==========================================================================
-// Copyright (c) PinkParrot Group
-// All rights reserved.
-// ==========================================================================
-
-using PinkParrot.Core.Schema;
-
-namespace PinkParrot.Write.Schema.Commands
-{
- public class UpdateModelSchema : TenantCommand
- {
- public ModelSchemaProperties Properties { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/AddModelField.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/AddField.cs
similarity index 81%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/AddModelField.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/AddField.cs
index b62a66ca4..44d72b814 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/AddModelField.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/AddField.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// AddModelField.cs
+// AddField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,9 +8,9 @@
using Newtonsoft.Json.Linq;
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class AddModelField : TenantCommand
+ public class AddField : TenantCommand
{
public string Name { get; set; }
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/CreateModelSchema.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/CreateSchema.cs
similarity index 64%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/CreateModelSchema.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/CreateSchema.cs
index 9bce9a9b2..472dab565 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/CreateModelSchema.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/CreateSchema.cs
@@ -1,19 +1,19 @@
// ==========================================================================
-// CreateModelSchema.cs
+// CreateSchema.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class CreateModelSchema : TenantCommand
+ public class CreateSchema : TenantCommand
{
public string Name { get; set; }
- public ModelSchemaProperties Properties { get; set; }
+ public SchemaProperties Properties { get; set; }
}
}
\ No newline at end of file
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DeleteModelField.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DeleteField.cs
similarity index 76%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DeleteModelField.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DeleteField.cs
index f8ec9ad64..cbf2950ff 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DeleteModelField.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DeleteField.cs
@@ -1,14 +1,13 @@
// ==========================================================================
-// DeleteModelField.cs
+// DeleteField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class DeleteModelField : TenantCommand
+ public class DeleteField : TenantCommand
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DeleteModelSchema.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DeleteSchema.cs
similarity index 73%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DeleteModelSchema.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DeleteSchema.cs
index 7c5ff662b..61f30be9f 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DeleteModelSchema.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DeleteSchema.cs
@@ -1,14 +1,13 @@
// ==========================================================================
-// DeleteModelSchema.cs
+// DeleteSchema.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class DeleteModelSchema : TenantCommand
+ public class DeleteSchema : TenantCommand
{
}
}
\ No newline at end of file
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/ShowModelField.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DisableField.cs
similarity index 77%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/ShowModelField.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DisableField.cs
index 8668851a2..fff582301 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/ShowModelField.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/DisableField.cs
@@ -1,14 +1,13 @@
// ==========================================================================
-// ShowModelField.cs
+// DisableField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class ShowModelField : TenantCommand
+ public class DisableField : TenantCommand
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/HideModelField.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/EnableField.cs
similarity index 77%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/HideModelField.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/EnableField.cs
index a8b24e445..17417d552 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/HideModelField.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/EnableField.cs
@@ -1,14 +1,13 @@
// ==========================================================================
-// HideModelField.cs
+// EnableField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class HideModelField : TenantCommand
+ public class EnableField : TenantCommand
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/EnableModelField.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/HideField.cs
similarity index 76%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/EnableModelField.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/HideField.cs
index feeba187e..1d9f25c83 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/EnableModelField.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/HideField.cs
@@ -1,14 +1,13 @@
// ==========================================================================
-// EnableModelField.cs
+// HideField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class EnableModelField : TenantCommand
+ public class HideField : TenantCommand
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DisableModelField.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/ShowField.cs
similarity index 76%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DisableModelField.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/ShowField.cs
index d931649a9..231098c13 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/DisableModelField.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/ShowField.cs
@@ -1,14 +1,13 @@
// ==========================================================================
-// DisableModelField.cs
+// ShowField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
// All rights reserved.
// ==========================================================================
-
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class DisableModelField : TenantCommand
+ public class ShowField : TenantCommand
{
public long FieldId { get; set; }
}
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/UpdateModelField.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/UpdateField.cs
similarity index 79%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/Commands/UpdateModelField.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/UpdateField.cs
index a1f88bdd3..8e307182f 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/Commands/UpdateModelField.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/UpdateField.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// UpdateModelField.cs
+// UpdateField.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -8,9 +8,9 @@
using Newtonsoft.Json.Linq;
-namespace PinkParrot.Write.Schema.Commands
+namespace PinkParrot.Write.Schemas.Commands
{
- public class UpdateModelField : TenantCommand
+ public class UpdateField : TenantCommand
{
public long FieldId { get; set; }
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/UpdateSchema.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/UpdateSchema.cs
new file mode 100644
index 000000000..dfd36b11e
--- /dev/null
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/Commands/UpdateSchema.cs
@@ -0,0 +1,17 @@
+// ==========================================================================
+// UpdateSchema.cs
+// PinkParrot Headless CMS
+// ==========================================================================
+// Copyright (c) PinkParrot Group
+// All rights reserved.
+// ==========================================================================
+
+using PinkParrot.Core.Schemas;
+
+namespace PinkParrot.Write.Schemas.Commands
+{
+ public class UpdateSchema : TenantCommand
+ {
+ public SchemaProperties Properties { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/ModelSchemaCommandHandler.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/SchemaCommandHandler.cs
similarity index 72%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/ModelSchemaCommandHandler.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/SchemaCommandHandler.cs
index be9a3a751..c99b0eadc 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/ModelSchemaCommandHandler.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/SchemaCommandHandler.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelSchemaCommandHandler.cs
+// SchemaCommandHandler.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -10,21 +10,21 @@ using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-using PinkParrot.Core.Schema;
+using PinkParrot.Core.Schemas;
using PinkParrot.Infrastructure;
using PinkParrot.Infrastructure.CQRS.Commands;
using PinkParrot.Infrastructure.Dispatching;
-using PinkParrot.Write.Schema.Commands;
+using PinkParrot.Write.Schemas.Commands;
-namespace PinkParrot.Write.Schema
+namespace PinkParrot.Write.Schemas
{
- public class ModelSchemaCommandHandler : CommandHandler
+ public class SchemaCommandHandler : CommandHandler
{
- private readonly ModelFieldRegistry registry;
+ private readonly FieldRegistry registry;
private readonly JsonSerializer serializer;
- public ModelSchemaCommandHandler(
- ModelFieldRegistry registry,
+ public SchemaCommandHandler(
+ FieldRegistry registry,
IDomainObjectFactory domainObjectFactory,
IDomainObjectRepository domainObjectRepository,
JsonSerializer serializer)
@@ -40,47 +40,47 @@ namespace PinkParrot.Write.Schema
return context.IsHandled ? Task.FromResult(false) : this.DispatchActionAsync(context.Command);
}
- public Task On(CreateModelSchema command)
+ public Task On(CreateSchema command)
{
return CreateAsync(command, s => s.Create(command.TenantId, command.Name, command.Properties));
}
- public Task On(DeleteModelSchema command)
+ public Task On(DeleteSchema command)
{
return UpdateAsync(command, s => s.Delete());
}
- public Task On(DeleteModelField command)
+ public Task On(DeleteField command)
{
return UpdateAsync(command, s => s.DeleteField(command.FieldId));
}
- public Task On(DisableModelField command)
+ public Task On(DisableField command)
{
return UpdateAsync(command, s => s.DisableField(command.FieldId));
}
- public Task On(EnableModelField command)
+ public Task On(EnableField command)
{
return UpdateAsync(command, s => s.EnableField(command.FieldId));
}
- public Task On(HideModelField command)
+ public Task On(HideField command)
{
return UpdateAsync(command, s => s.HideField(command.FieldId));
}
- public Task On(ShowModelField command)
+ public Task On(ShowField command)
{
return UpdateAsync(command, s => s.ShowField(command.FieldId));
}
- public Task On(UpdateModelSchema command)
+ public Task On(UpdateSchema command)
{
return UpdateAsync(command, s => s.Update(command.Properties));
}
- public Task On(AddModelField command)
+ public Task On(AddField command)
{
var propertiesType = registry.FindByTypeName(command.Type).PropertiesType;
var propertiesValue = CreateProperties(command.Properties, propertiesType);
@@ -88,7 +88,7 @@ namespace PinkParrot.Write.Schema
return UpdateAsync(command, s => s.AddField(command.Name, propertiesValue));
}
- public Task On(UpdateModelField command)
+ public Task On(UpdateField command)
{
return UpdateAsync(command, s =>
{
@@ -96,7 +96,7 @@ namespace PinkParrot.Write.Schema
if (field == null)
{
- throw new DomainObjectNotFoundException(command.FieldId.ToString(), typeof(ModelField));
+ throw new DomainObjectNotFoundException(command.FieldId.ToString(), typeof(Field));
}
var propertiesType = registry.FindByPropertiesType(field.RawProperties.GetType()).PropertiesType;
@@ -106,9 +106,9 @@ namespace PinkParrot.Write.Schema
});
}
- private IModelFieldProperties CreateProperties(JToken token, Type type)
+ private IFieldProperties CreateProperties(JToken token, Type type)
{
- return (IModelFieldProperties)token.ToObject(type, serializer);
+ return (IFieldProperties)token.ToObject(type, serializer);
}
}
}
diff --git a/src/pinkparrot_write/PinkParrot.Write/Schema/ModelSchemaDomainObject.cs b/src/pinkparrot_write/PinkParrot.Write/Schemas/SchemaDomainObject.cs
similarity index 62%
rename from src/pinkparrot_write/PinkParrot.Write/Schema/ModelSchemaDomainObject.cs
rename to src/pinkparrot_write/PinkParrot.Write/Schemas/SchemaDomainObject.cs
index 38919c7af..9c3b12094 100644
--- a/src/pinkparrot_write/PinkParrot.Write/Schema/ModelSchemaDomainObject.cs
+++ b/src/pinkparrot_write/PinkParrot.Write/Schemas/SchemaDomainObject.cs
@@ -1,5 +1,5 @@
// ==========================================================================
-// ModelSchemaDomainObject.cs
+// SchemaDomainObject.cs
// PinkParrot Headless CMS
// ==========================================================================
// Copyright (c) PinkParrot Group
@@ -7,24 +7,24 @@
// ==========================================================================
using System;
-using PinkParrot.Core.Schema;
-using PinkParrot.Events.Schema;
+using PinkParrot.Core.Schemas;
+using PinkParrot.Events.Schemas;
using PinkParrot.Infrastructure;
using PinkParrot.Infrastructure.CQRS;
using PinkParrot.Infrastructure.CQRS.Events;
using PinkParrot.Infrastructure.Dispatching;
-namespace PinkParrot.Write.Schema
+namespace PinkParrot.Write.Schemas
{
- public class ModelSchemaDomainObject : DomainObject, ITenantAggregate
+ public class SchemaDomainObject : DomainObject, ITenantAggregate
{
- private readonly ModelFieldRegistry registry;
+ private readonly FieldRegistry registry;
private Guid tenantId;
private bool isDeleted;
private long totalFields;
- private ModelSchema schema;
+ private Schema schema;
- public ModelSchema Schema
+ public Schema Schema
{
get { return schema; }
}
@@ -39,7 +39,7 @@ namespace PinkParrot.Write.Schema
get { return isDeleted; }
}
- public ModelSchemaDomainObject(Guid id, int version, ModelFieldRegistry registry)
+ public SchemaDomainObject(Guid id, int version, FieldRegistry registry)
: base(id, version)
{
Guard.NotNull(registry, nameof(registry));
@@ -47,128 +47,128 @@ namespace PinkParrot.Write.Schema
this.registry = registry;
}
- public void On(ModelFieldAdded @event)
+ public void On(FieldAdded @event)
{
totalFields++;
schema = schema.AddOrUpdateField(registry.CreateField(@event.FieldId, @event.Name, @event.Properties));
}
- public void On(ModelSchemaCreated @event)
+ public void On(SchemaCreated @event)
{
tenantId = @event.TenantId;
- schema = ModelSchema.Create(@event.Name, @event.Properties);
+ schema = Schema.Create(@event.Name, @event.Properties);
}
- public void On(ModelFieldUpdated @event)
+ public void On(FieldUpdated @event)
{
schema = schema.UpdateField(@event.FieldId, @event.Properties);
}
- public void On(ModelFieldHidden @event)
+ public void On(FieldHidden @event)
{
schema = schema.HideField(@event.FieldId);
}
- public void On(ModelFieldShown @event)
+ public void On(FieldShown @event)
{
schema = schema.ShowField(@event.FieldId);
}
- public void On(ModelFieldDisabled @event)
+ public void On(FieldDisabled @event)
{
schema = schema.DisableField(@event.FieldId);
}
- public void On(ModelFieldEnabled @event)
+ public void On(FieldEnabled @event)
{
schema = schema.EnableField(@event.FieldId);
}
- public void On(ModelSchemaUpdated @event)
+ public void On(SchemaUpdated @event)
{
schema = schema.Update(@event.Properties);
}
- public void On(ModelFieldDeleted @event)
+ public void On(FieldDeleted @event)
{
schema = schema.DeleteField(@event.FieldId);
}
- public void On(ModelSchemaDeleted @event)
+ public void On(SchemaDeleted @event)
{
isDeleted = false;
}
- public void AddField(string name, IModelFieldProperties properties)
+ public void AddField(string name, IFieldProperties properties)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelFieldAdded { FieldId = ++totalFields, Name = name, Properties = properties });
+ RaiseEvent(new FieldAdded { FieldId = ++totalFields, Name = name, Properties = properties });
}
- public void Create(Guid newTenantId, string name, ModelSchemaProperties properties)
+ public void Create(Guid newTenantId, string name, SchemaProperties properties)
{
VerifyNotCreated();
- RaiseEvent(new ModelSchemaCreated { TenantId = newTenantId, Name = name, Properties = properties });
+ RaiseEvent(new SchemaCreated { TenantId = newTenantId, Name = name, Properties = properties });
}
- public void Update(ModelSchemaProperties properties)
+ public void Update(SchemaProperties properties)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelSchemaUpdated { Properties = properties });
+ RaiseEvent(new SchemaUpdated { Properties = properties });
}
- public void UpdateField(long fieldId, IModelFieldProperties properties)
+ public void UpdateField(long fieldId, IFieldProperties properties)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelFieldUpdated { FieldId = fieldId, Properties = properties });
+ RaiseEvent(new FieldUpdated { FieldId = fieldId, Properties = properties });
}
public void HideField(long fieldId)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelFieldHidden { FieldId = fieldId });
+ RaiseEvent(new FieldHidden { FieldId = fieldId });
}
public void ShowField(long fieldId)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelFieldShown { FieldId = fieldId });
+ RaiseEvent(new FieldShown { FieldId = fieldId });
}
public void DisableField(long fieldId)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelFieldDisabled { FieldId = fieldId });
+ RaiseEvent(new FieldDisabled { FieldId = fieldId });
}
public void EnableField(long fieldId)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelFieldEnabled { FieldId = fieldId });
+ RaiseEvent(new FieldEnabled { FieldId = fieldId });
}
public void DeleteField(long fieldId)
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelFieldDeleted { FieldId = fieldId });
+ RaiseEvent(new FieldDeleted { FieldId = fieldId });
}
public void Delete()
{
VerifyCreatedAndNotDeleted();
- RaiseEvent(new ModelSchemaDeleted());
+ RaiseEvent(new SchemaDeleted());
}
private void VerifyNotCreated()