public static string DisplayName(this StringSuggestionState state) { if (!Enum.IsDefined(typeof(StringSuggestionState), state)) { return("Unknown"); } return(typeof(StringSuggestionState) .GetMember(state.ToString()) .First() .GetCustomAttribute <DisplayAttribute>() .Name); }
public static string BadgeClassForState(StringSuggestionState state) { switch (state) { case StringSuggestionState.Created: return("badge-secondary"); case StringSuggestionState.ApprovedByReviewer: case StringSuggestionState.ApprovedByTrustedUser: return("badge-success"); case StringSuggestionState.Rejected: return("badge-danger"); case StringSuggestionState.DeletedByOwner: return("badge-dark"); default: return(null); } }
public static NotificationType?GetNotificationType(this StringSuggestionState state) { switch (state) { case StringSuggestionState.ApprovedByTrustedUser: return(NotificationType.SuggestionsApproved); case StringSuggestionState.ApprovedByReviewer: return(NotificationType.SuggestionsReviewed); case StringSuggestionState.Rejected: return(NotificationType.SuggestionsRejected); case StringSuggestionState.DismissedByOtherString: return(NotificationType.SuggestionsOverriden); case StringSuggestionState.Created: case StringSuggestionState.DeletedByOwner: return(null); default: throw new ArgumentException($"Missing NotificationType for {state}"); } }