diff --git a/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/BookingCreateDto.g.cs b/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/BookingCreateDto.g.cs index 1fef500d87..3964c46f45 100644 --- a/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/BookingCreateDto.g.cs +++ b/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/BookingCreateDto.g.cs @@ -65,11 +65,6 @@ public abstract class BookingCreateDtoBase : IEntityDto /// public virtual System.DateTimeOffset? CancelledDateTime { get; set; } /// - /// Booking's status - /// Optional - /// - public virtual System.String? Status { get; set; } - /// /// Booking's related vat number /// Optional /// diff --git a/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CashStockOrderCreateDto.g.cs b/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CashStockOrderCreateDto.g.cs index 20b656c641..6f63325645 100644 --- a/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CashStockOrderCreateDto.g.cs +++ b/samples/Cryptocash.Api/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CashStockOrderCreateDto.g.cs @@ -43,11 +43,6 @@ public abstract class CashStockOrderCreateDtoBase : IEntityDtoOptional /// public virtual System.DateTimeOffset? DeliveryDateTime { get; set; } - /// - /// Order status - /// Optional - /// - public virtual System.String? Status { get; set; } /// /// CashStockOrder for ExactlyOne VendingMachines diff --git a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CountryCreateDto.g.cs b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CountryCreateDto.g.cs index 8758f8838d..434b46e7f9 100644 --- a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CountryCreateDto.g.cs +++ b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/CountryCreateDto.g.cs @@ -47,11 +47,6 @@ public abstract class CountryCreateDtoBase : IEntityDto /// public virtual System.String? FirstLanguageCode { get; set; } /// - /// The Formula - /// Optional - /// - public virtual System.String? ShortDescription { get; set; } - /// /// Country's iso number id /// Optional /// diff --git a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseCreateDto.g.cs b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseCreateDto.g.cs index a696cd32bd..dc70c49fe2 100644 --- a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseCreateDto.g.cs +++ b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseCreateDto.g.cs @@ -31,13 +31,6 @@ public abstract class StoreLicenseCreateDtoBase : IEntityDto - /// License external id - /// Required - /// - [Required(ErrorMessage = "ExternalId is required")] - - public virtual System.Int64 ExternalId { get; set; } = default!; /// /// StoreLicense Store that this license related to ExactlyOne Stores diff --git a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseUpdateDto.g.cs b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseUpdateDto.g.cs index b59f21205e..fe5c4891e0 100644 --- a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseUpdateDto.g.cs +++ b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/StoreLicenseUpdateDto.g.cs @@ -24,13 +24,6 @@ public partial class StoreLicenseUpdateDto : IEntityDto - /// License external id - /// Required. - /// - [Required(ErrorMessage = "ExternalId is required")] - - public System.Int64 ExternalId { get; set; } = default!; /// /// StoreLicense Store that this license related to ExactlyOne Stores diff --git a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/WorkplaceCreateDto.g.cs b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/WorkplaceCreateDto.g.cs index 40c89cd569..9ac7ed9e60 100644 --- a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/WorkplaceCreateDto.g.cs +++ b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/WorkplaceCreateDto.g.cs @@ -36,11 +36,6 @@ public abstract class WorkplaceCreateDtoBase : IEntityDtoOptional /// public virtual System.String? Description { get; set; } - /// - /// The Formula - /// Optional - /// - public virtual System.String? Greeting { get; set; } /// /// Workplace Workplace country ZeroOrOne Countries diff --git a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/StoreLicenseFactory.g.cs b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/StoreLicenseFactory.g.cs index 783b9e7d24..04943653a3 100644 --- a/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/StoreLicenseFactory.g.cs +++ b/src/Nox.ClientApi.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/StoreLicenseFactory.g.cs @@ -58,7 +58,6 @@ private ClientApi.Domain.StoreLicense ToEntity(StoreLicenseCreateDto createDto) private void UpdateEntityInternal(StoreLicenseEntity entity, StoreLicenseUpdateDto updateDto, Nox.Types.CultureCode cultureCode) { entity.Issuer = ClientApi.Domain.StoreLicenseMetadata.CreateIssuer(updateDto.Issuer.NonNullValue()); - entity.ExternalId = ClientApi.Domain.StoreLicenseMetadata.CreateExternalId(updateDto.ExternalId.NonNullValue()); } private void PartialUpdateEntityInternal(StoreLicenseEntity entity, Dictionary updatedProperties, Nox.Types.CultureCode cultureCode) @@ -74,17 +73,6 @@ private void PartialUpdateEntityInternal(StoreLicenseEntity entity, Dictionary(Endpoints.CurrenciesUrl, new CurrencyCreateDto { Id = "USD" }); var eurCurrency = await PostAsync(Endpoints.CurrenciesUrl, new CurrencyCreateDto { Id = "EUR" }); - var store = await CreateStore(); + var store = await CreateStoreAsync(); var storeLicenseReponse = await PostAsync(Endpoints.StoreLicensesUrl, new StoreLicenseCreateDto { Issuer = _fixture.Create(), @@ -72,8 +72,8 @@ public async Task Post_RefToCurrency_Succes() public async Task Put_UpdateRelatedStore_Success() { //Arrange - var store1 = await CreateStore(); - var store2 = await CreateStore(); + var store1 = await CreateStoreAsync(); + var store2 = await CreateStoreAsync(); var storeLicenseResponse = await PostAsync(Endpoints.StoreLicensesUrl, new StoreLicenseCreateDto { @@ -102,7 +102,7 @@ await PutAsync($"{Endpoints.StoreLicense public async Task Put_UpdateRelatedStoreToEmpty_Fail() { //Arrange - var store1 = await CreateStore(); + var store1 = await CreateStoreAsync(); var storeLicenseResponse = await PostAsync(Endpoints.StoreLicensesUrl, new StoreLicenseCreateDto { @@ -140,8 +140,8 @@ public async Task GetById_WithRelationshipSet_ReturnsValidData() { var issuer = _fixture.Create(); // Arrange - var store = await CreateStore(); - var store2 = await CreateStore(); + var store = await CreateStoreAsync(); + var store2 = await CreateStoreAsync(); var createDto = new StoreLicenseCreateDto { @@ -169,7 +169,7 @@ public async Task GetById_WithRelationshipNotSet_ReturnsValidData() { var issuer = _fixture.Create(); // Arrange - StoreDto? store = await CreateStore(); + StoreDto? store = await CreateStoreAsync(); var createDto = new StoreLicenseCreateDto { @@ -195,8 +195,8 @@ public async Task GetById_WithRelationshipNotSet_ReturnsValidData() public async Task WhenStoreLicenceCreated_ShouldGenerateAutoNumberExternalId() { //Arrange - var store1 = await CreateStore(); - var store2 = await CreateStore(); + var store1 = await CreateStoreAsync(); + var store2 = await CreateStoreAsync(); // Act var storeLicenseResponse = await PostAsync(Endpoints.StoreLicensesUrl, @@ -215,13 +215,61 @@ public async Task WhenStoreLicenceCreated_ShouldGenerateAutoNumberExternalId() //Assert storeLicenseResponse.Should().NotBeNull(); - storeLicenseResponse!.ExternalId.Should().BeGreaterOrEqualTo(30000); + storeLicenseResponse!.ExternalId.Should().Be(3000000); storeLicenseResponse2.Should().NotBeNull(); - storeLicenseResponse2!.ExternalId.Should().BeGreaterOrEqualTo(30000 + 10); + storeLicenseResponse2!.ExternalId.Should().Be(3000000 + 10); } - private async Task CreateStore() + [Fact] + public async Task WhenStoreLicenceCreated_AutoNumberExternalIdIsSystemGenerated() + { + //Arrange + var store = await CreateStoreAsync(); + var storeLicenseCreateResponse = await PostAsync(Endpoints.StoreLicensesUrl, + new + { + Issuer = _fixture.Create(), + StoreId = store!.Id, + ExternalId = 123456 + }); + + // Act + //Assert + storeLicenseCreateResponse.Should().NotBeNull(); + storeLicenseCreateResponse!.ExternalId.Should().Be(3000000); + } + + [Fact] + public async Task WhenStoreLicenceUpdated_AutoNumberExternalIdIsNotUpdated() + { + //Arrange + var store = await CreateStoreAsync(); + var storeLicenseCreateResponse = await PostAsync(Endpoints.StoreLicensesUrl, + new + { + Issuer = _fixture.Create(), + StoreId = store!.Id, + }); + var externalId = storeLicenseCreateResponse!.ExternalId; + + // Act + var headers = CreateEtagHeader(storeLicenseCreateResponse!.Etag); + var storeLicenseUpdateResponse = await PutAsync($"{Endpoints.StoreLicensesUrl}/{storeLicenseCreateResponse!.Id}", + new + { + Issuer = _fixture.Create(), + StoreId = store!.Id, + ExternalId = 123456 + }, + headers); + + //Assert + storeLicenseUpdateResponse.Should().NotBeNull(); + storeLicenseUpdateResponse!.ExternalId.Should().Be(externalId); + } + + private async Task CreateStoreAsync() { var createDto = new StoreCreateDto { diff --git a/src/Nox.Generator.Tasks/Common/ScribanScriptsExtensions.cs b/src/Nox.Generator.Tasks/Common/ScribanScriptsExtensions.cs index 7defdf6094..4847d61ea3 100644 --- a/src/Nox.Generator.Tasks/Common/ScribanScriptsExtensions.cs +++ b/src/Nox.Generator.Tasks/Common/ScribanScriptsExtensions.cs @@ -21,11 +21,11 @@ public static void AddFunctions(TemplateContext context, NoxSolution noxSolution NoxType>(noxSolution.GetSingleTypeForKey)); var scriptObject3 = new ScriptObject(); - scriptObject2.Import("SingleKeyPrimitiveTypeForEntity", new Func(noxSolution.GetSingleKeyPrimitiveTypeForEntity)); var scriptObject4 = new ScriptObject(); - scriptObject2.Import("SinglePrimitiveTypeForKey", new Func(noxSolution.GetSinglePrimitiveTypeForKey)); var scriptObject5 = new ScriptObject(); @@ -37,19 +37,23 @@ public static void AddFunctions(TemplateContext context, NoxSolution noxSolution bool>(type => type.IsUpdatableType())); var scriptObject7 = new ScriptObject(); - scriptObject7.Import("IsNoxTypeSimpleType", new Func(type => type.IsSimpleType())); + scriptObject7.Import("IsNoxTypeCreatable", new Func(type => type.IsCreatableType())); var scriptObject8 = new ScriptObject(); - scriptObject8.Import("IsValueType", new Func(type => Type.GetType(type)?.IsValueType ?? false)); + scriptObject8.Import("IsNoxTypeSimpleType", new Func(type => type.IsSimpleType())); var scriptObject9 = new ScriptObject(); - scriptObject9.Import("Pluralize", new Func(type => Type.GetType(type)?.IsValueType ?? false)); + + var scriptObject10 = new ScriptObject(); + scriptObject10.Import("Pluralize", new Func(name => name.Pluralize())); - var scriptObject10 = new ScriptObject(); - scriptObject10.Import("ToLowerFirstChar", new Func( + var scriptObject11 = new ScriptObject(); + scriptObject11.Import("ToLowerFirstChar", new Func( input => input.ToLowerFirstChar())); @@ -63,5 +67,6 @@ public static void AddFunctions(TemplateContext context, NoxSolution noxSolution context.PushGlobal(scriptObject8); context.PushGlobal(scriptObject9); context.PushGlobal(scriptObject10); + context.PushGlobal(scriptObject11); } } \ No newline at end of file diff --git a/src/Nox.Generator/Application/Dto/EntityCreateDto.template.cs b/src/Nox.Generator/Application/Dto/EntityCreateDto.template.cs index 71c3cdb986..fd9708929d 100644 --- a/src/Nox.Generator/Application/Dto/EntityCreateDto.template.cs +++ b/src/Nox.Generator/Application/Dto/EntityCreateDto.template.cs @@ -48,6 +48,9 @@ public abstract class {{className}}Base : IEntityDto /// {{attribute.Description | string.rstrip}} /// {{if attribute.IsRequired}}Required{{else}}Optional{{end}} diff --git a/src/Nox.Generator/Application/Factories/EntityFactory.template.cs b/src/Nox.Generator/Application/Factories/EntityFactory.template.cs index b2bc99efcb..6481b92a3b 100644 --- a/src/Nox.Generator/Application/Factories/EntityFactory.template.cs +++ b/src/Nox.Generator/Application/Factories/EntityFactory.template.cs @@ -112,7 +112,7 @@ public virtual void PartialUpdateEntity({{entity.Name}}Entity entity, Dictionary private void UpdateEntityInternal({{entity.Name}}Entity entity, {{entity.Name}}UpdateDto updateDto, Nox.Types.CultureCode cultureCode) { {{- for attribute in entity.Attributes }} - {{- if !IsNoxTypeReadable attribute.Type || attribute.Type == "Formula" -}} + {{- if !IsNoxTypeReadable attribute.Type || !IsNoxTypeUpdatable attribute.Type -}} {{ continue; }} {{- end}} {{ if attribute.IsLocalized }}if(IsDefaultCultureCode(cultureCode)) {{ end }} @@ -139,7 +139,7 @@ private void UpdateEntityInternal({{entity.Name}}Entity entity, {{entity.Name}}U private void PartialUpdateEntityInternal({{entity.Name}}Entity entity, Dictionary updatedProperties, Nox.Types.CultureCode cultureCode) { {{- for attribute in entity.Attributes }} - {{- if !IsNoxTypeReadable attribute.Type || attribute.Type == "Formula" -}} + {{- if !IsNoxTypeReadable attribute.Type || !IsNoxTypeUpdatable attribute.Type -}} {{ continue; }} {{- end}} diff --git a/src/Nox.Generator/Common/ScribanScriptsExtensions.cs b/src/Nox.Generator/Common/ScribanScriptsExtensions.cs index 65f1f83ccb..cde4a74098 100644 --- a/src/Nox.Generator/Common/ScribanScriptsExtensions.cs +++ b/src/Nox.Generator/Common/ScribanScriptsExtensions.cs @@ -40,31 +40,35 @@ public static void AddFunctions(TemplateContext context, NoxSolution noxSolution bool>(type => type.IsUpdatableType())); var scriptObject7 = new ScriptObject(); - scriptObject7.Import("IsNoxTypeSimpleType", new Func(type => type.IsSimpleType())); + scriptObject7.Import("IsNoxTypeCreatable", new Func(type => type.IsCreatableType())); var scriptObject8 = new ScriptObject(); - scriptObject8.Import("IsValueType", new Func(type => Type.GetType(type)?.IsValueType ?? false)); + scriptObject8.Import("IsNoxTypeSimpleType", new Func(type => type.IsSimpleType())); var scriptObject9 = new ScriptObject(); - scriptObject9.Import("Pluralize", new Func(type => Type.GetType(type)?.IsValueType ?? false)); + + var scriptObject10 = new ScriptObject(); + scriptObject10.Import("Pluralize", new Func(name => name.Pluralize())); - var scriptObject10 = new ScriptObject(); - scriptObject10.Import("ToLowerFirstChar", new Func( + var scriptObject11 = new ScriptObject(); + scriptObject11.Import("ToLowerFirstChar", new Func( input => input.ToLowerFirstChar())); - var scriptObject11 = new ScriptObject(); - scriptObject11.Import("GetEntityNameForLocalizedType", new Func( + var scriptObject12 = new ScriptObject(); + scriptObject12.Import("GetEntityNameForLocalizedType", new Func( entityName => NoxCodeGenConventions.GetEntityNameForLocalizedType(entityName))); - var scriptObject12 = new ScriptObject(); - scriptObject12.Import("GetEntityDtoNameForLocalizedType", new Func( + var scriptObject13 = new ScriptObject(); + scriptObject13.Import("GetEntityDtoNameForLocalizedType", new Func( entityName => NoxCodeGenConventions.GetEntityDtoNameForLocalizedType(entityName))); - var scriptObject13 = new ScriptObject(); - scriptObject13.Import("GetNavigationPropertyName", new Func( + var scriptObject14 = new ScriptObject(); + scriptObject14.Import("GetNavigationPropertyName", new Func( (entity, relationship) => entity.GetNavigationPropertyName(relationship))); context.PushGlobal(scriptObject1); @@ -80,5 +84,6 @@ public static void AddFunctions(TemplateContext context, NoxSolution noxSolution context.PushGlobal(scriptObject11); context.PushGlobal(scriptObject12); context.PushGlobal(scriptObject13); + context.PushGlobal(scriptObject14); } } \ No newline at end of file diff --git a/src/Nox.Types.Abstractions/Attributes/Types/CompoundTypeAttribute.cs b/src/Nox.Types.Abstractions/Attributes/Types/CompoundTypeAttribute.cs index 2fcc6dcaf0..e0792d436a 100644 --- a/src/Nox.Types.Abstractions/Attributes/Types/CompoundTypeAttribute.cs +++ b/src/Nox.Types.Abstractions/Attributes/Types/CompoundTypeAttribute.cs @@ -10,10 +10,12 @@ public class CompoundTypeAttribute : Attribute, IDtoGenerateControl { public virtual bool Read { get; set; } public virtual bool Update { get; set; } + public virtual bool Create { get; set; } - public CompoundTypeAttribute(bool read = true, bool update = true) + public CompoundTypeAttribute(bool read = true, bool update = true, bool create = true) { Read = read; Update = update; + Create = create; } } diff --git a/src/Nox.Types.Abstractions/Attributes/Types/IDtoGenerateControl.cs b/src/Nox.Types.Abstractions/Attributes/Types/IDtoGenerateControl.cs index d698d51b55..b76a5003e7 100644 --- a/src/Nox.Types.Abstractions/Attributes/Types/IDtoGenerateControl.cs +++ b/src/Nox.Types.Abstractions/Attributes/Types/IDtoGenerateControl.cs @@ -4,4 +4,5 @@ internal interface IDtoGenerateControl { public bool Read { get; set; } public bool Update { get; set; } + public bool Create { get; set; } } diff --git a/src/Nox.Types.Abstractions/Attributes/Types/SimpleTypeAttribute.cs b/src/Nox.Types.Abstractions/Attributes/Types/SimpleTypeAttribute.cs index 416f976e7c..eeb41400d7 100644 --- a/src/Nox.Types.Abstractions/Attributes/Types/SimpleTypeAttribute.cs +++ b/src/Nox.Types.Abstractions/Attributes/Types/SimpleTypeAttribute.cs @@ -12,8 +12,9 @@ public class SimpleTypeAttribute : Attribute, IDtoGenerateControl public virtual bool Read { get; set; } public virtual bool Update { get; set; } + public virtual bool Create { get; set; } - public SimpleTypeAttribute(Type underlyingType, bool read = true, bool update = true) + public SimpleTypeAttribute(Type underlyingType, bool read = true, bool update = true, bool create = true) { if (typeof(INoxTypeComponentsDiscover).IsAssignableFrom(underlyingType)) { @@ -26,5 +27,6 @@ public SimpleTypeAttribute(Type underlyingType, bool read = true, bool update = Read = read; Update = update; + Create = create; } } \ No newline at end of file diff --git a/src/Nox.Types.Abstractions/Enums/NoxType.cs b/src/Nox.Types.Abstractions/Enums/NoxType.cs index e5038da677..4d60a14e74 100644 --- a/src/Nox.Types.Abstractions/Enums/NoxType.cs +++ b/src/Nox.Types.Abstractions/Enums/NoxType.cs @@ -106,7 +106,7 @@ public enum NoxType : uint [SimpleType(typeof(short))] CurrencyNumber = 2377452890, - [SimpleType(typeof(long))] + [SimpleType(typeof(long), Update = false, Create = false)] AutoNumber = 24779567, [SimpleType(typeof(DateTime))] @@ -140,7 +140,7 @@ public enum NoxType : uint [SimpleType(typeof(int))] Enumeration = 3545666060, - [SimpleType(typeof(string), Update = false)] + [SimpleType(typeof(string), Update = false, Create = false)] Formula = 2602269623, [SimpleType(typeof(Guid))] diff --git a/src/Nox.Types.Abstractions/Extensions/NoxTypeExtensions.cs b/src/Nox.Types.Abstractions/Extensions/NoxTypeExtensions.cs index f18454fe81..b220ab33ab 100644 --- a/src/Nox.Types.Abstractions/Extensions/NoxTypeExtensions.cs +++ b/src/Nox.Types.Abstractions/Extensions/NoxTypeExtensions.cs @@ -64,6 +64,11 @@ public static bool IsUpdatableType(this NoxType noxType) return (noxType.DtoGenerateControl()?.Update) ?? true; } + public static bool IsCreatableType(this NoxType noxType) + { + return (noxType.DtoGenerateControl()?.Create) ?? true; + } + private static IDtoGenerateControl? DtoGenerateControl(this NoxType noxType) { if (noxType.IsSimpleType()) diff --git a/tests/Nox.Generator.Tests/Domain/QueryTests.cs b/tests/Nox.Generator.Tests/Domain/QueryTests.cs index eb4ab9605b..6653603074 100644 --- a/tests/Nox.Generator.Tests/Domain/QueryTests.cs +++ b/tests/Nox.Generator.Tests/Domain/QueryTests.cs @@ -25,7 +25,9 @@ public void Can_generate_domain_query_files() var filesShouldExist = new[] { "Application.Dto.CountryDto.g.cs", - "Application.Dto.CountryCreateDto.g.cs" + "Application.Dto.CountryCreateDto.g.cs", + "Application.Dto.CountryUpdateDto.g.cs", + "Application.Factories.CountryFactory.g.cs" }; _fixture @@ -34,6 +36,8 @@ public void Can_generate_domain_query_files() .AssertFileCount(8, filesShouldExist) .AssertContent() .WithExpectedFilesFolder("./ExpectedGeneratedFiles") - .AssertFileExistsAndContent("Dto.CountryCreateDto.expected.g.cs", "Application.Dto.CountryCreateDto.g.cs"); + .AssertFileExistsAndContent("Dto.CountryCreateDto.expected.g.cs", "Application.Dto.CountryCreateDto.g.cs") + .AssertFileExistsAndContent("Dto.CountryUpdateDto.expected.g.cs", "Application.Dto.CountryUpdateDto.g.cs") + .AssertFileExistsAndContent("Application.Factories.CountryFactory.expected.g.cs", "Application.Factories.CountryFactory.g.cs"); } } \ No newline at end of file diff --git a/tests/Nox.Generator.Tests/ExpectedGeneratedFiles/Application.Factories.CountryFactory.expected.g.cs b/tests/Nox.Generator.Tests/ExpectedGeneratedFiles/Application.Factories.CountryFactory.expected.g.cs new file mode 100644 index 0000000000..6826bebb45 --- /dev/null +++ b/tests/Nox.Generator.Tests/ExpectedGeneratedFiles/Application.Factories.CountryFactory.expected.g.cs @@ -0,0 +1,255 @@ +// Generated + +#nullable enable + +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.EntityFrameworkCore; + +using MediatR; + +using Nox.Abstractions; +using Nox.Solution; +using Nox.Domain; +using Nox.Application.Factories; +using Nox.Types; +using Nox.Application; +using Nox.Extensions; +using Nox.Exceptions; + +using SampleWebApp.Application.Dto; +using SampleWebApp.Domain; +using CountryEntity = SampleWebApp.Domain.Country; + +namespace SampleWebApp.Application.Factories; + +internal abstract class CountryFactoryBase : IEntityFactory +{ + private static readonly Nox.Types.CultureCode _defaultCultureCode = Nox.Types.CultureCode.From("en-US"); + + public CountryFactoryBase + ( + ) + { + } + + public virtual CountryEntity CreateEntity(CountryCreateDto createDto) + { + return ToEntity(createDto); + } + + public virtual void UpdateEntity(CountryEntity entity, CountryUpdateDto updateDto, Nox.Types.CultureCode cultureCode) + { + UpdateEntityInternal(entity, updateDto, cultureCode); + } + + public virtual void PartialUpdateEntity(CountryEntity entity, Dictionary updatedProperties, Nox.Types.CultureCode cultureCode) + { + PartialUpdateEntityInternal(entity, updatedProperties, cultureCode); + } + + private SampleWebApp.Domain.Country ToEntity(CountryCreateDto createDto) + { + var entity = new SampleWebApp.Domain.Country(); + entity.Id = CountryMetadata.CreateId(createDto.Id); + entity.Name = SampleWebApp.Domain.CountryMetadata.CreateName(createDto.Name); + entity.FormalName = SampleWebApp.Domain.CountryMetadata.CreateFormalName(createDto.FormalName); + entity.AlphaCode3 = SampleWebApp.Domain.CountryMetadata.CreateAlphaCode3(createDto.AlphaCode3); + entity.AlphaCode2 = SampleWebApp.Domain.CountryMetadata.CreateAlphaCode2(createDto.AlphaCode2); + entity.NumericCode = SampleWebApp.Domain.CountryMetadata.CreateNumericCode(createDto.NumericCode); + entity.SetIfNotNull(createDto.DialingCodes, (entity) => entity.DialingCodes =SampleWebApp.Domain.CountryMetadata.CreateDialingCodes(createDto.DialingCodes.NonNullValue())); + entity.SetIfNotNull(createDto.Capital, (entity) => entity.Capital =SampleWebApp.Domain.CountryMetadata.CreateCapital(createDto.Capital.NonNullValue())); + entity.SetIfNotNull(createDto.Demonym, (entity) => entity.Demonym =SampleWebApp.Domain.CountryMetadata.CreateDemonym(createDto.Demonym.NonNullValue())); + entity.AreaInSquareKilometres = SampleWebApp.Domain.CountryMetadata.CreateAreaInSquareKilometres(createDto.AreaInSquareKilometres); + entity.SetIfNotNull(createDto.GeoCoord, (entity) => entity.GeoCoord =SampleWebApp.Domain.CountryMetadata.CreateGeoCoord(createDto.GeoCoord.NonNullValue())); + entity.GeoRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoRegion(createDto.GeoRegion); + entity.GeoSubRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoSubRegion(createDto.GeoSubRegion); + entity.GeoWorldRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoWorldRegion(createDto.GeoWorldRegion); + entity.SetIfNotNull(createDto.Population, (entity) => entity.Population =SampleWebApp.Domain.CountryMetadata.CreatePopulation(createDto.Population.NonNullValue())); + entity.SetIfNotNull(createDto.TopLevelDomains, (entity) => entity.TopLevelDomains =SampleWebApp.Domain.CountryMetadata.CreateTopLevelDomains(createDto.TopLevelDomains.NonNullValue())); + return entity; + } + + private void UpdateEntityInternal(CountryEntity entity, CountryUpdateDto updateDto, Nox.Types.CultureCode cultureCode) + { + entity.Name = SampleWebApp.Domain.CountryMetadata.CreateName(updateDto.Name.NonNullValue()); + entity.FormalName = SampleWebApp.Domain.CountryMetadata.CreateFormalName(updateDto.FormalName.NonNullValue()); + entity.AlphaCode3 = SampleWebApp.Domain.CountryMetadata.CreateAlphaCode3(updateDto.AlphaCode3.NonNullValue()); + entity.AlphaCode2 = SampleWebApp.Domain.CountryMetadata.CreateAlphaCode2(updateDto.AlphaCode2.NonNullValue()); + entity.NumericCode = SampleWebApp.Domain.CountryMetadata.CreateNumericCode(updateDto.NumericCode.NonNullValue()); + entity.SetIfNotNull(updateDto.DialingCodes, (entity) => entity.DialingCodes = SampleWebApp.Domain.CountryMetadata.CreateDialingCodes(updateDto.DialingCodes.ToValueFromNonNull())); + entity.SetIfNotNull(updateDto.Capital, (entity) => entity.Capital = SampleWebApp.Domain.CountryMetadata.CreateCapital(updateDto.Capital.ToValueFromNonNull())); + entity.SetIfNotNull(updateDto.Demonym, (entity) => entity.Demonym = SampleWebApp.Domain.CountryMetadata.CreateDemonym(updateDto.Demonym.ToValueFromNonNull())); + entity.AreaInSquareKilometres = SampleWebApp.Domain.CountryMetadata.CreateAreaInSquareKilometres(updateDto.AreaInSquareKilometres.NonNullValue()); + entity.SetIfNotNull(updateDto.GeoCoord, (entity) => entity.GeoCoord = SampleWebApp.Domain.CountryMetadata.CreateGeoCoord(updateDto.GeoCoord.ToValueFromNonNull())); + entity.GeoRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoRegion(updateDto.GeoRegion.NonNullValue()); + entity.GeoSubRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoSubRegion(updateDto.GeoSubRegion.NonNullValue()); + entity.GeoWorldRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoWorldRegion(updateDto.GeoWorldRegion.NonNullValue()); + entity.SetIfNotNull(updateDto.Population, (entity) => entity.Population = SampleWebApp.Domain.CountryMetadata.CreatePopulation(updateDto.Population.ToValueFromNonNull())); + entity.SetIfNotNull(updateDto.TopLevelDomains, (entity) => entity.TopLevelDomains = SampleWebApp.Domain.CountryMetadata.CreateTopLevelDomains(updateDto.TopLevelDomains.ToValueFromNonNull())); + } + + private void PartialUpdateEntityInternal(CountryEntity entity, Dictionary updatedProperties, Nox.Types.CultureCode cultureCode) + { + + if (updatedProperties.TryGetValue("Name", out var NameUpdateValue)) + { + if (NameUpdateValue == null) + { + throw new ArgumentException("Attribute 'Name' can't be null"); + } + { + entity.Name = SampleWebApp.Domain.CountryMetadata.CreateName(NameUpdateValue); + } + } + + if (updatedProperties.TryGetValue("FormalName", out var FormalNameUpdateValue)) + { + if (FormalNameUpdateValue == null) + { + throw new ArgumentException("Attribute 'FormalName' can't be null"); + } + { + entity.FormalName = SampleWebApp.Domain.CountryMetadata.CreateFormalName(FormalNameUpdateValue); + } + } + + if (updatedProperties.TryGetValue("AlphaCode3", out var AlphaCode3UpdateValue)) + { + if (AlphaCode3UpdateValue == null) + { + throw new ArgumentException("Attribute 'AlphaCode3' can't be null"); + } + { + entity.AlphaCode3 = SampleWebApp.Domain.CountryMetadata.CreateAlphaCode3(AlphaCode3UpdateValue); + } + } + + if (updatedProperties.TryGetValue("AlphaCode2", out var AlphaCode2UpdateValue)) + { + if (AlphaCode2UpdateValue == null) + { + throw new ArgumentException("Attribute 'AlphaCode2' can't be null"); + } + { + entity.AlphaCode2 = SampleWebApp.Domain.CountryMetadata.CreateAlphaCode2(AlphaCode2UpdateValue); + } + } + + if (updatedProperties.TryGetValue("NumericCode", out var NumericCodeUpdateValue)) + { + if (NumericCodeUpdateValue == null) + { + throw new ArgumentException("Attribute 'NumericCode' can't be null"); + } + { + entity.NumericCode = SampleWebApp.Domain.CountryMetadata.CreateNumericCode(NumericCodeUpdateValue); + } + } + + if (updatedProperties.TryGetValue("DialingCodes", out var DialingCodesUpdateValue)) + { + if (DialingCodesUpdateValue == null) { entity.DialingCodes = null; } + else + { + entity.DialingCodes = SampleWebApp.Domain.CountryMetadata.CreateDialingCodes(DialingCodesUpdateValue); + } + } + + if (updatedProperties.TryGetValue("Capital", out var CapitalUpdateValue)) + { + if (CapitalUpdateValue == null) { entity.Capital = null; } + else + { + entity.Capital = SampleWebApp.Domain.CountryMetadata.CreateCapital(CapitalUpdateValue); + } + } + + if (updatedProperties.TryGetValue("Demonym", out var DemonymUpdateValue)) + { + if (DemonymUpdateValue == null) { entity.Demonym = null; } + else + { + entity.Demonym = SampleWebApp.Domain.CountryMetadata.CreateDemonym(DemonymUpdateValue); + } + } + + if (updatedProperties.TryGetValue("AreaInSquareKilometres", out var AreaInSquareKilometresUpdateValue)) + { + if (AreaInSquareKilometresUpdateValue == null) + { + throw new ArgumentException("Attribute 'AreaInSquareKilometres' can't be null"); + } + { + entity.AreaInSquareKilometres = SampleWebApp.Domain.CountryMetadata.CreateAreaInSquareKilometres(AreaInSquareKilometresUpdateValue); + } + } + + if (updatedProperties.TryGetValue("GeoCoord", out var GeoCoordUpdateValue)) + { + if (GeoCoordUpdateValue == null) { entity.GeoCoord = null; } + else + { + entity.GeoCoord = SampleWebApp.Domain.CountryMetadata.CreateGeoCoord(GeoCoordUpdateValue); + } + } + + if (updatedProperties.TryGetValue("GeoRegion", out var GeoRegionUpdateValue)) + { + if (GeoRegionUpdateValue == null) + { + throw new ArgumentException("Attribute 'GeoRegion' can't be null"); + } + { + entity.GeoRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoRegion(GeoRegionUpdateValue); + } + } + + if (updatedProperties.TryGetValue("GeoSubRegion", out var GeoSubRegionUpdateValue)) + { + if (GeoSubRegionUpdateValue == null) + { + throw new ArgumentException("Attribute 'GeoSubRegion' can't be null"); + } + { + entity.GeoSubRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoSubRegion(GeoSubRegionUpdateValue); + } + } + + if (updatedProperties.TryGetValue("GeoWorldRegion", out var GeoWorldRegionUpdateValue)) + { + if (GeoWorldRegionUpdateValue == null) + { + throw new ArgumentException("Attribute 'GeoWorldRegion' can't be null"); + } + { + entity.GeoWorldRegion = SampleWebApp.Domain.CountryMetadata.CreateGeoWorldRegion(GeoWorldRegionUpdateValue); + } + } + + if (updatedProperties.TryGetValue("Population", out var PopulationUpdateValue)) + { + if (PopulationUpdateValue == null) { entity.Population = null; } + else + { + entity.Population = SampleWebApp.Domain.CountryMetadata.CreatePopulation(PopulationUpdateValue); + } + } + + if (updatedProperties.TryGetValue("TopLevelDomains", out var TopLevelDomainsUpdateValue)) + { + if (TopLevelDomainsUpdateValue == null) { entity.TopLevelDomains = null; } + else + { + entity.TopLevelDomains = SampleWebApp.Domain.CountryMetadata.CreateTopLevelDomains(TopLevelDomainsUpdateValue); + } + } + } + + private static bool IsDefaultCultureCode(Nox.Types.CultureCode cultureCode) + => cultureCode == _defaultCultureCode; +} + +internal partial class CountryFactory : CountryFactoryBase +{ +} \ No newline at end of file diff --git a/tests/Nox.Generator.Tests/ExpectedGeneratedFiles/Dto.CountryUpdateDto.expected.g.cs b/tests/Nox.Generator.Tests/ExpectedGeneratedFiles/Dto.CountryUpdateDto.expected.g.cs new file mode 100644 index 0000000000..1806590e55 --- /dev/null +++ b/tests/Nox.Generator.Tests/ExpectedGeneratedFiles/Dto.CountryUpdateDto.expected.g.cs @@ -0,0 +1,113 @@ +// Generated + +#nullable enable +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +using Nox.Abstractions; +using Nox.Application.Dto; +using Nox.Types; + +using DomainNamespace = SampleWebApp.Domain; + +namespace SampleWebApp.Application.Dto; + +/// +/// The list of countries +/// +public partial class CountryUpdateDto : IEntityDto +{ + /// + /// The country's common name + /// Required. + /// + [Required(ErrorMessage = "Name is required")] + + public System.String Name { get; set; } = default!; + /// + /// The country's official name + /// Required. + /// + [Required(ErrorMessage = "FormalName is required")] + + public System.String FormalName { get; set; } = default!; + /// + /// The country's official ISO 4217 alpha-3 code + /// Required. + /// + [Required(ErrorMessage = "AlphaCode3 is required")] + + public System.String AlphaCode3 { get; set; } = default!; + /// + /// The country's official ISO 4217 alpha-2 code + /// Required. + /// + [Required(ErrorMessage = "AlphaCode2 is required")] + + public System.String AlphaCode2 { get; set; } = default!; + /// + /// The country's official ISO 4217 alpha-3 code + /// Required. + /// + [Required(ErrorMessage = "NumericCode is required")] + + public System.Int16 NumericCode { get; set; } = default!; + /// + /// The country's phone dialing codes (comma-delimited) + /// Optional. + /// + public System.String? DialingCodes { get; set; } + /// + /// The capital city of the country + /// Optional. + /// + public System.String? Capital { get; set; } + /// + /// Noun denoting the natives of the country + /// Optional. + /// + public System.String? Demonym { get; set; } + /// + /// Country area in square kilometers + /// Required. + /// + [Required(ErrorMessage = "AreaInSquareKilometres is required")] + + public System.Int32 AreaInSquareKilometres { get; set; } = default!; + /// + /// The the position of the workplace's point on the surface of the Earth + /// Optional. + /// + public LatLongDto? GeoCoord { get; set; } + /// + /// The region the country is in + /// Required. + /// + [Required(ErrorMessage = "GeoRegion is required")] + + public System.String GeoRegion { get; set; } = default!; + /// + /// The sub-region the country is in + /// Required. + /// + [Required(ErrorMessage = "GeoSubRegion is required")] + + public System.String GeoSubRegion { get; set; } = default!; + /// + /// The world region the country is in + /// Required. + /// + [Required(ErrorMessage = "GeoWorldRegion is required")] + + public System.String GeoWorldRegion { get; set; } = default!; + /// + /// The estimated population of the country + /// Optional. + /// + public System.Int32? Population { get; set; } + /// + /// The top level internet domains regitered to the country (comma-delimited) + /// Optional. + /// + public System.String? TopLevelDomains { get; set; } +} \ No newline at end of file diff --git a/tests/Nox.Generator.Tests/files/yaml/domain/query.solution.nox.yaml b/tests/Nox.Generator.Tests/files/yaml/domain/query.solution.nox.yaml index faffb1ea38..a2b361710f 100644 --- a/tests/Nox.Generator.Tests/files/yaml/domain/query.solution.nox.yaml +++ b/tests/Nox.Generator.Tests/files/yaml/domain/query.solution.nox.yaml @@ -189,3 +189,10 @@ domain: - name: PasswordField description: Password Nox Type type: password + + - name: AutoNumberField + description: AutoNumber Nox Type + type: autoNumber + autoNumberTypeOptions: + startsAt: 10 + incrementsBy: 5 diff --git a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesCreateDto.g.cs b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesCreateDto.g.cs index 1ff411abcc..ba3c9a4b36 100644 --- a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesCreateDto.g.cs +++ b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesCreateDto.g.cs @@ -24,20 +24,6 @@ public partial class TestEntityForAutoNumberUsagesCreateDto : TestEntityForAutoN /// public abstract class TestEntityForAutoNumberUsagesCreateDtoBase : IEntityDto { - /// - /// - /// Required - /// - [Required(ErrorMessage = "AutoNumberFieldWithOptions is required")] - - public virtual System.Int64 AutoNumberFieldWithOptions { get; set; } = default!; - /// - /// - /// Required - /// - [Required(ErrorMessage = "AutoNumberFieldWithoutOptions is required")] - - public virtual System.Int64 AutoNumberFieldWithoutOptions { get; set; } = default!; /// /// /// Required diff --git a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesUpdateDto.g.cs b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesUpdateDto.g.cs index 1dc4fd29b4..c52411850b 100644 --- a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesUpdateDto.g.cs +++ b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForAutoNumberUsagesUpdateDto.g.cs @@ -17,20 +17,6 @@ namespace TestWebApp.Application.Dto; /// public partial class TestEntityForAutoNumberUsagesUpdateDto : IEntityDto { - /// - /// - /// Required. - /// - [Required(ErrorMessage = "AutoNumberFieldWithOptions is required")] - - public System.Int64 AutoNumberFieldWithOptions { get; set; } = default!; - /// - /// - /// Required. - /// - [Required(ErrorMessage = "AutoNumberFieldWithoutOptions is required")] - - public System.Int64 AutoNumberFieldWithoutOptions { get; set; } = default!; /// /// /// Required. diff --git a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesCreateDto.g.cs b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesCreateDto.g.cs index b76201214e..435b07f725 100644 --- a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesCreateDto.g.cs +++ b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesCreateDto.g.cs @@ -298,18 +298,6 @@ public abstract class TestEntityForTypesCreateDtoBase : IEntityDtoOptional /// - public virtual System.String? FormulaTestField { get; set; } - /// - /// - /// Required - /// - [Required(ErrorMessage = "AutoNumberTestField is required")] - - public virtual System.Int64 AutoNumberTestField { get; set; } = default!; - /// - /// - /// Optional - /// public virtual System.String? HtmlTestField { get; set; } /// /// diff --git a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesUpdateDto.g.cs b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesUpdateDto.g.cs index 20b8180f45..877ae93d9f 100644 --- a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesUpdateDto.g.cs +++ b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Dto/TestEntityForTypesUpdateDto.g.cs @@ -268,13 +268,6 @@ public partial class TestEntityForTypesUpdateDto : IEntityDto /// - /// Required. - /// - [Required(ErrorMessage = "AutoNumberTestField is required")] - - public System.Int64 AutoNumberTestField { get; set; } = default!; - /// - /// /// Optional. /// public System.String? HtmlTestField { get; set; } diff --git a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForAutoNumberUsagesFactory.g.cs b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForAutoNumberUsagesFactory.g.cs index c6afa7cc3c..16d652bb64 100644 --- a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForAutoNumberUsagesFactory.g.cs +++ b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForAutoNumberUsagesFactory.g.cs @@ -57,36 +57,12 @@ private TestWebApp.Domain.TestEntityForAutoNumberUsages ToEntity(TestEntityForAu private void UpdateEntityInternal(TestEntityForAutoNumberUsagesEntity entity, TestEntityForAutoNumberUsagesUpdateDto updateDto, Nox.Types.CultureCode cultureCode) { - entity.AutoNumberFieldWithOptions = TestWebApp.Domain.TestEntityForAutoNumberUsagesMetadata.CreateAutoNumberFieldWithOptions(updateDto.AutoNumberFieldWithOptions.NonNullValue()); - entity.AutoNumberFieldWithoutOptions = TestWebApp.Domain.TestEntityForAutoNumberUsagesMetadata.CreateAutoNumberFieldWithoutOptions(updateDto.AutoNumberFieldWithoutOptions.NonNullValue()); entity.TextField = TestWebApp.Domain.TestEntityForAutoNumberUsagesMetadata.CreateTextField(updateDto.TextField.NonNullValue()); } private void PartialUpdateEntityInternal(TestEntityForAutoNumberUsagesEntity entity, Dictionary updatedProperties, Nox.Types.CultureCode cultureCode) { - if (updatedProperties.TryGetValue("AutoNumberFieldWithOptions", out var AutoNumberFieldWithOptionsUpdateValue)) - { - if (AutoNumberFieldWithOptionsUpdateValue == null) - { - throw new ArgumentException("Attribute 'AutoNumberFieldWithOptions' can't be null"); - } - { - entity.AutoNumberFieldWithOptions = TestWebApp.Domain.TestEntityForAutoNumberUsagesMetadata.CreateAutoNumberFieldWithOptions(AutoNumberFieldWithOptionsUpdateValue); - } - } - - if (updatedProperties.TryGetValue("AutoNumberFieldWithoutOptions", out var AutoNumberFieldWithoutOptionsUpdateValue)) - { - if (AutoNumberFieldWithoutOptionsUpdateValue == null) - { - throw new ArgumentException("Attribute 'AutoNumberFieldWithoutOptions' can't be null"); - } - { - entity.AutoNumberFieldWithoutOptions = TestWebApp.Domain.TestEntityForAutoNumberUsagesMetadata.CreateAutoNumberFieldWithoutOptions(AutoNumberFieldWithoutOptionsUpdateValue); - } - } - if (updatedProperties.TryGetValue("TextField", out var TextFieldUpdateValue)) { if (TextFieldUpdateValue == null) diff --git a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForTypesFactory.g.cs b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForTypesFactory.g.cs index a1ee92c63f..7a859d483e 100644 --- a/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForTypesFactory.g.cs +++ b/tests/Nox.Integration.Tests/Generated/Nox.Generator/Nox.Generator.NoxCodeGenerator/Application.Factories/TestEntityForTypesFactory.g.cs @@ -157,7 +157,6 @@ private void UpdateEntityInternal(TestEntityForTypesEntity entity, TestEntityFor entity.SetIfNotNull(updateDto.UrlTestField, (entity) => entity.UrlTestField = TestWebApp.Domain.TestEntityForTypesMetadata.CreateUrlTestField(updateDto.UrlTestField.ToValueFromNonNull())); entity.SetIfNotNull(updateDto.DateTimeScheduleTestField, (entity) => entity.DateTimeScheduleTestField = TestWebApp.Domain.TestEntityForTypesMetadata.CreateDateTimeScheduleTestField(updateDto.DateTimeScheduleTestField.ToValueFromNonNull())); entity.SetIfNotNull(updateDto.UserTestField, (entity) => entity.UserTestField = TestWebApp.Domain.TestEntityForTypesMetadata.CreateUserTestField(updateDto.UserTestField.ToValueFromNonNull())); - entity.AutoNumberTestField = TestWebApp.Domain.TestEntityForTypesMetadata.CreateAutoNumberTestField(updateDto.AutoNumberTestField.NonNullValue()); entity.SetIfNotNull(updateDto.HtmlTestField, (entity) => entity.HtmlTestField = TestWebApp.Domain.TestEntityForTypesMetadata.CreateHtmlTestField(updateDto.HtmlTestField.ToValueFromNonNull())); entity.SetIfNotNull(updateDto.ImageTestField, (entity) => entity.ImageTestField = TestWebApp.Domain.TestEntityForTypesMetadata.CreateImageTestField(updateDto.ImageTestField.ToValueFromNonNull())); } @@ -610,17 +609,6 @@ private void PartialUpdateEntityInternal(TestEntityForTypesEntity entity, Dictio } } - if (updatedProperties.TryGetValue("AutoNumberTestField", out var AutoNumberTestFieldUpdateValue)) - { - if (AutoNumberTestFieldUpdateValue == null) - { - throw new ArgumentException("Attribute 'AutoNumberTestField' can't be null"); - } - { - entity.AutoNumberTestField = TestWebApp.Domain.TestEntityForTypesMetadata.CreateAutoNumberTestField(AutoNumberTestFieldUpdateValue); - } - } - if (updatedProperties.TryGetValue("HtmlTestField", out var HtmlTestFieldUpdateValue)) { if (HtmlTestFieldUpdateValue == null) { entity.HtmlTestField = null; }