I have this mailer application that sends out articles everyday to employees who have subscribed for it.
These articles are manually updated everyday. Since there is no one there to manually update the article on Saturday and Sunday, employees are not supposed to receive an article the following days Sunday and Monday. I have been successful in implementing that logic.
DataSet newsData = this._biData.GetAutomailListNotes(user.UserId,
categories, newsEmailSentDateTime);
DayOfWeek dayOfTheWeek = this._configurationOverrides?.DayOfTheWeekOverride ??
DateTime.Today.DayOfWeek;
// if user has an article to be sent. Morning Markets are not sent on Sunday nor Monday
if (newsData.Tables[0].Rows.Count > 0 ||
(isMorningMarketsUser && dayOfTheWeek != DayOfWeek.Sunday &&
dayOfTheWeek != DayOfWeek.Monday))
Now my client wants me to implement a logic that covers holidays as well.
In the database we have a "Createdate" column. It stores the date and time when the article was created. I want to implement a logic that says if the article is created after the user received the mailer today then send the mailer tomorrow again with the new articles otherwise do not send it. User can subscribe for multiple articles. I am not even sure if this is a good strategy though. Any recommendations would be appreciated.
I personally think that you need to segregate your code to recognize the holiday from other logic.
Create a function for the same, use free online api services such as this one here to figure out whether this particular day is holiday or not, return the result back to your main logic.
Hope that helps.