Reputation: 658
I am building a custom CMS in ASP.NET MVC and one of the requirements is that the content has a start and end date that dictates whether or not the page appears on the site. What is the best approach to this? Should I run some sort of chron job to mark the status of the page according to its publish dates? Does anyone have any resources or advice on the matter?
Upvotes: 0
Views: 144
Reputation: 1220
You seem eager to make model responsible for choosing active items.
Depending on the size (count) of the items you query, to preserve response time.
if you have many items, you better use a windows service to mark active items.
also you can index the column you use to mark active items.
alternatively, you can make the View responsible for displaying or hiding the item
foreach(var item in Model)
if(Item.DisplayAllowed) renderpartial("ItemView",item);
Upvotes: 0
Reputation: 190945
Why not just do something like this
bool visible = true;
if (startdate > now || enddate < now)
visible = false;
That way you don't have to have another process.
Upvotes: 1