-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
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
@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/") ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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/") ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
@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/") ) |
There was a problem hiding this comment.
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