forked from nopSolutions/nopCommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nopSolutions#2364 Add preview button for News, Topics, Blogs
- Loading branch information
1 parent
c1f4fcc
commit 48e53c1
Showing
12 changed files
with
269 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
|
||
namespace Nop.Core.Domain.News | ||
{ | ||
/// <summary> | ||
/// News item extensions | ||
/// </summary> | ||
public static class NewsExtensions | ||
{ | ||
/// <summary> | ||
/// Get a value indicating whether a news item is available now (availability dates) | ||
/// </summary> | ||
/// <param name="newsItem">News item</param> | ||
/// <returns>Result</returns> | ||
public static bool IsAvailable(this NewsItem newsItem) | ||
{ | ||
return IsAvailable(newsItem, DateTime.UtcNow); | ||
} | ||
|
||
/// <summary> | ||
/// Get a value indicating whether a news item is available now (availability dates) | ||
/// </summary> | ||
/// <param name="newsItem">News item</param> | ||
/// <param name="dateTime">Datetime to check</param> | ||
/// <returns>Result</returns> | ||
public static bool IsAvailable(this NewsItem newsItem, DateTime dateTime) | ||
{ | ||
if (newsItem == null) | ||
throw new ArgumentNullException(nameof(newsItem)); | ||
|
||
if (newsItem.StartDateUtc.HasValue && newsItem.StartDateUtc.Value >= dateTime) | ||
{ | ||
return false; | ||
} | ||
|
||
if (newsItem.EndDateUtc.HasValue && newsItem.EndDateUtc.Value <= dateTime) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.