Skip to content

Commit

Permalink
fix: handle textBodyDB entity being empty - possible fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uahussain12 committed Jan 25, 2024
1 parent 34661b2 commit 5ad8a11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Dfe.PlanTech.Domain/Content/Interfaces/IHasRichText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Dfe.PlanTech.Domain.Content.Interfaces;
public interface IHasRichText
{
public RichTextContentDbEntity RichText { get; set; }
public long RichTextId { get; }
public long? RichTextId { get; }
}
2 changes: 1 addition & 1 deletion src/Dfe.PlanTech.Domain/Content/Models/TextBodyDbEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TextBodyDbEntity : ContentComponentDbEntity, ITextBody<RichTextCont
{
public RichTextContentDbEntity RichText { get; set; } = null!;

public long RichTextId { get; set; }
public long? RichTextId { get; set; }

public List<WarningComponentDbEntity> Warnings { get; set; } = new();
}
17 changes: 12 additions & 5 deletions src/Dfe.PlanTech.Domain/Content/Models/WarningComponentDbEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ public class WarningComponentDbEntity : ContentComponentDbEntity, IWarningCompon
public string TextId { get; set; } = null!;
public TextBodyDbEntity Text { get; set; } = null!;

[NotMapped]
[NotMapped][DontCopyValue]
public RichTextContentDbEntity RichText
{
get => Text.RichText;
set => Text.RichText = value;
get => Text?.RichText;

Check warning on line 15 in src/Dfe.PlanTech.Domain/Content/Models/WarningComponentDbEntity.cs

View workflow job for this annotation

GitHub Actions / Run E2E Tests

Possible null reference return.

Check warning on line 15 in src/Dfe.PlanTech.Domain/Content/Models/WarningComponentDbEntity.cs

View workflow job for this annotation

GitHub Actions / Build and run unit tests

Possible null reference return.

Check warning on line 15 in src/Dfe.PlanTech.Domain/Content/Models/WarningComponentDbEntity.cs

View workflow job for this annotation

GitHub Actions / Build and run unit tests

Possible null reference return.
set
{
if (Text != null)
{
Text.RichText = value;
}
}
}

[NotMapped]
public long RichTextId => Text.RichTextId;
[NotMapped][DontCopyValue]
public long? RichTextId => Text?.RichTextId;

}

0 comments on commit 5ad8a11

Please sign in to comment.