Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TNO-2566: Evening Overview Error #1796

Merged
merged 1 commit into from
May 9, 2024
Merged

Conversation

areyeslo
Copy link
Collaborator

@areyeslo areyeslo commented May 8, 2024

  • Filtering null values in FileReferences before querying for content.
  • New migration for Weekday and Weekend Evening Overview Templates.

* New migration to Update Weekend/Week template for Evenining Overview
@areyeslo areyeslo added bug Something isn't working DB Migration A DB Migration may require refreshing or simply updating your database. labels May 8, 2024
@if (item.ContentId.HasValue)
{
<a href="@($"{ViewContentUrl}{item.ContentId}")">@summary</a>
@if (item.Content.FileReferences != null && item.Content.FileReferences.Any() && item.Content.FileReferences.FirstOrDefault().ContentType.StartsWith("video/") )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.FirstOrDefault() can result in a null value. This will fail if there is a null value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added item.Content.FileReferences.Any() to check if there is any content and just in that case obtain the first record with contentType starting with 'video'. If item.Content.FileReferences.Any() returns false then it does not proceed to the rest of the conditional if statement, so it would not execute FirstOrDefault().

Please let me know if I should check for another way to implement it.

Thank you!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will work. You can also do item.Content.FileReferences.FirstOrDefault()?.ContentType.StartsWith("video/") == true

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@if (item.ContentId.HasValue)
{
<a href="@($"{ViewContentUrl}{item.ContentId}")">@summary</a>
@if (item.Content.FileReferences != null && item.Content.FileReferences.Any() && item.Content.FileReferences.FirstOrDefault().ContentType.StartsWith("video/") )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.FirstOrDefault() can result in a null value. This will fail if there is a null value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added item.Content.FileReferences.Any() to check if there is any content and just in that case obtain the first record with contentType starting with 'video'. If item.Content.FileReferences.Any() returns false then it does not proceed to the rest of the conditional if statement, so it would not execute FirstOrDefault().

Please let me know if I should check for another way to implement it.

Thank you!

@areyeslo areyeslo requested a review from Fosol May 9, 2024 16:20
@if (item.ContentId.HasValue)
{
<a href="@($"{ViewContentUrl}{item.ContentId}")">@summary</a>
@if (item.Content.FileReferences != null && item.Content.FileReferences.Any() && item.Content.FileReferences.FirstOrDefault().ContentType.StartsWith("video/") )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will work. You can also do item.Content.FileReferences.FirstOrDefault()?.ContentType.StartsWith("video/") == true

@Fosol Fosol merged commit 24e0c29 into dev May 9, 2024
1 check passed
@Fosol Fosol deleted the TNO-2566-EveningOverviewError branch May 9, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DB Migration A DB Migration may require refreshing or simply updating your database.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants