public string GetMessage(IEnumerable <User> users, LocalMemoizer <string, Issue> issueMemoizer, Func <string, string> issueUrlGetter) { var user = UserId.IfPoss(id => users.FirstOrDefault(u => u.Id == id)); switch (Type) { case HistoryItemType.CreatedByRuleAdjustment: return("Issue was created by adjustment of rules of {0} by {1}.".FormatWith(issueUrlGetter(SpawningIssueId), GetUserString(user))); case HistoryItemType.ManuallyCreated: return("Issue was created manually by <span class=\"bold\">{0}</span> with status <span class=\"bold\">{1}</span>, assigned to <span class=\"bold\">{2}</span>".FormatWith(GetUserString(user), PreviousStatus, AssignedToUserId)); case HistoryItemType.AssignedUserChanged: return("Status was updated from {0} to {1} by {2}.".FormatWith(PreviousStatus, NewStatus, GetUserString(user))); case HistoryItemType.MergedTo: return("Issue was created by adjustment of rules of issue {0} by <span class=\"bold\">{1}</span>.".FormatWith(issueUrlGetter(SpawningIssueId), GetUserString(user))); case HistoryItemType.ErrorsPurged: return("All errors attached to this issue were deleted by <span class=\"bold\">{0}</span>.".FormatWith(GetUserString(user))); case HistoryItemType.ErrorsReprocessed: return("All errors associated with this issue were re-processed by <span class=\"bold\">{0}</span>.<br />{1}".FormatWith( GetUserString(user), new ReprocessIssueErrorsResponse { AttachedIssueIds = ReprocessingResult, Status = ReprocessIssueErrorsStatus.Ok }.GetMessage(IssueId))); case HistoryItemType.Comment: return(Comment); case HistoryItemType.RulesAdjustedCreatedNewIssue: return("Issue rules were adjusted by <span class=\"bold\">{0}</span>. Errors that no longer match this issue got attached to issue {1}.".FormatWith(GetUserString(user), issueUrlGetter(SpawnedIssueId))); case HistoryItemType.RulesAdjustedNoNewIssue: return("Issue rules were adjusted by <span class=\"bold\">{0}</span>. All errors stayed attached to this issue.".FormatWith(GetUserString(user))); case HistoryItemType.AutoCreated: return("Issue created by new error of type <span class=\"bold\">{0}</span> in method <span class=\"bold\">{1}</span> on machine <span class=\"bold\">{2}</span>".FormatWith(HttpUtility.HtmlEncode(ExceptionType), HttpUtility.HtmlEncode(ExceptionMethod), HttpUtility.HtmlEncode(ExceptionMachine))); case HistoryItemType.StatusUpdated: return("Status was updated from <span class=\"bold\">{0}</span> to <span class=\"bold\">{1}</span> by <span class=\"bold\">{2}</span>.".FormatWith(PreviousStatus, NewStatus, GetUserString(user))); default: return("No message"); } }