Skip to content

Commit

Permalink
Test has been fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
msadikkoseaupa committed Nov 14, 2023
1 parent 3be9f3e commit c4b8dae
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 90 deletions.
22 changes: 11 additions & 11 deletions samples/Cryptocash.Ui/Nox.Generated/Generator.g.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Generated

#nullable enable

// Using Nox version 7.0.92.0

/* Found files ->
// Generated

#nullable enable

// Using Nox version 7.0.92.0

/* Found files ->
- cryptocash.application.nox.yaml
- CountrySync.integration.nox.yaml
- cryptocash.solution.nox.yaml
Expand Down Expand Up @@ -65,7 +65,7 @@
- VendingMachineEndpoints.md
- IntegrationEvents.md
- README.md
- generator.nox.yaml
Logging Verbosity Minimal
SUCCESS.
*/
- generator.nox.yaml
Logging Verbosity Minimal
SUCCESS.
*/

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public async Task Put_NewLanguageDescription_CreatesLocalization()
CreateEtagHeader(postResult?.Etag),
CreateAcceptLanguageHeader("en-US"));

var localizedDto = await PatchAsync<WorkplaceLocalizedUpsertDto, WorkplaceLocalizedDto>($"{Endpoints.WorkplacesUrl}/{postResult!.Id}/WorkplaceLocalized/tr-TR", upsertDto, headers);
var localizedDto = await PutAsync<WorkplaceLocalizedUpsertDto, WorkplaceLocalizedDto>($"{Endpoints.WorkplacesUrl}/{postResult!.Id}/WorkplaceLocalized/tr-TR", upsertDto, headers, false);


// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace {{ codeGeneratorState.ODataNameSpace }};
public abstract partial class {{ entity.PluralName }}ControllerBase
{

[HttpPatch("api/{{entity.PluralName}}/{{keysRoute}}{{entity.Name}}Localized/{%{{}%}{{cultureCode}}{%{}}%}")]
public virtual async Task<ActionResult<{{entity.Name}}LocalizedDto>> Patch{{entity.Name}}Localized( {{ primaryKeysRoute }}, [FromRoute] System.String {{cultureCode}}, [FromBody] Delta<{{entity.Name}}LocalizedUpsertDto> {{ToLowerFirstChar entity.Name}}LocalizedUpsertDto)
[HttpPut("api/{{entity.PluralName}}/{{keysRoute}}{{entity.Name}}Localized/{%{{}%}{{cultureCode}}{%{}}%}")]
public virtual async Task<ActionResult<{{entity.Name}}LocalizedDto>> Put{{entity.Name}}Localized( {{ primaryKeysRoute }}, [FromRoute] System.String {{cultureCode}}, [FromBody] {{entity.Name}}LocalizedUpsertDto {{ToLowerFirstChar entity.Name}}LocalizedUpsertDto)
{
if (!ModelState.IsValid)
{
Expand All @@ -43,14 +43,11 @@ public abstract partial class {{ entity.PluralName }}ControllerBase

var updatedProperties = new Dictionary<string, dynamic>();
var etag = Request.GetDecodedEtagHeader();

{{- for attribute in entityAttributesToLocalize }}
updatedProperties.Add(nameof({{ToLowerFirstChar entity.Name}}LocalizedUpsertDto.{{attribute.Name}}), {{ToLowerFirstChar entity.Name}}LocalizedUpsertDto.{{attribute.Name}}.ToValueFromNonNull());
{{- end }}

foreach (var propertyName in {{ToLowerFirstChar entity.Name}}LocalizedUpsertDto.GetDynamicMemberNames())
{
if ({{ToLowerFirstChar entity.Name}}LocalizedUpsertDto.TryGetPropertyValue(propertyName, out dynamic value))
{
updatedProperties[propertyName] = value;
}
}
var updatedKey = await _mediator.Send(new PartialUpdate{{ entity.Name }}Command({{ primaryKeysQuery }}, updatedProperties, Nox.Types.CultureCode.From({{cultureCode}}) , etag));

if (updatedKey is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public override void Generate(
{
continue;
}

var entityAttributesToLocalize = entity.Attributes
.Where(x => x.IsLocalized);

var keysForRouting = GetPrimaryKeysQuery(entity).Split(',').Select(x => x.Trim()).ToList();

Expand All @@ -43,6 +46,7 @@ public override void Generate(
.WithObject("createdKeyPrimaryKeysQuery", GetPrimaryKeysQuery(entity, "createdKey.", true))
.WithObject("updatedKeyPrimaryKeysQuery", GetPrimaryKeysQuery(entity, "updatedKey.key", true))
.WithObject("keysForRouting", keysForRouting)
.WithObject("entityAttributesToLocalize", entityAttributesToLocalize)
.WithObject("entity", entity)
.GenerateSourceCodeFromResource(templateName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace TestWebApp.Presentation.Api.OData;
public abstract partial class TestEntityLocalizationsControllerBase
{

[HttpPatch("api/TestEntityLocalizations/{key}/TestEntityLocalizationLocalized/{cultureCode}")]
public virtual async Task<ActionResult<TestEntityLocalizationLocalizedDto>> PatchTestEntityLocalizationLocalized( [FromRoute] System.String key, [FromRoute] System.String cultureCode, [FromBody] Delta<TestEntityLocalizationLocalizedUpsertDto> testEntityLocalizationLocalizedUpsertDto)
[HttpPut("api/TestEntityLocalizations/{key}/TestEntityLocalizationLocalized/{cultureCode}")]
public virtual async Task<ActionResult<TestEntityLocalizationLocalizedDto>> PutTestEntityLocalizationLocalized( [FromRoute] System.String key, [FromRoute] System.String cultureCode, [FromBody] TestEntityLocalizationLocalizedUpsertDto testEntityLocalizationLocalizedUpsertDto)
{
if (!ModelState.IsValid)
{
Expand All @@ -39,14 +39,8 @@ public virtual async Task<ActionResult<TestEntityLocalizationLocalizedDto>> Patc

var updatedProperties = new Dictionary<string, dynamic>();
var etag = Request.GetDecodedEtagHeader();
updatedProperties.Add(nameof(testEntityLocalizationLocalizedUpsertDto.TextFieldToLocalize), testEntityLocalizationLocalizedUpsertDto.TextFieldToLocalize.ToValueFromNonNull());

foreach (var propertyName in testEntityLocalizationLocalizedUpsertDto.GetChangedPropertyNames())
{
if (testEntityLocalizationLocalizedUpsertDto.TryGetPropertyValue(propertyName, out dynamic value))
{
updatedProperties[propertyName] = value;
}
}
var updatedKey = await _mediator.Send(new PartialUpdateTestEntityLocalizationCommand(key, updatedProperties, Nox.Types.CultureCode.From(cultureCode) , etag));

if (updatedKey is null)
Expand Down

0 comments on commit c4b8dae

Please sign in to comment.