private string GetMailBodyForUser(Notifier.UserNotifications userNotifications) { var mailBody = new StringBuilder(); mailBody.Append("<html>"); mailBody.Append("<body>"); mailBody.Append($"<p>Hello {userNotifications.UserName}</p>"); mailBody.Append("<h1>Summary</h1>"); mailBody.Append("<p>"); mailBody.Append($"{userNotifications.SubscribedCardCount} registered cards<br/>"); mailBody.Append($"Search finished at {DateTime.UtcNow}<br/>"); mailBody.Append("</p>"); AddCardVersions(userNotifications.CardVersions, mailBody); AddCardDeletions(userNotifications.DeletedCards, mailBody); foreach (var searchNotifications in userNotifications.SearchNotificactions) { AddSearchNotifications(searchNotifications, mailBody); } mailBody.Append("</body>"); mailBody.Append("</html>"); return(mailBody.ToString()); }
private static bool MustSendForNotifications(Notifier.UserNotifications userNotifications) { if (userNotifications.CardVersions.Any()) { return(true); } if (userNotifications.DeletedCards.Any()) { return(true); } return(userNotifications.SearchNotificactions.Any(searchNotificaction => searchNotificaction.TotalNewlyFoundCardCount > 0 || searchNotificaction.CountOfCardsNotFoundAnymore_StillExists_UserAllowedToView > 0 || searchNotificaction.CountOfCardsNotFoundAnymore_Deleted_UserAllowedToView > 0 || searchNotificaction.CountOfCardsNotFoundAnymore_StillExists_UserNotAllowedToView > 0 || searchNotificaction.CountOfCardsNotFoundAnymore_Deleted_UserNotAllowedToView > 0 )); }