public static void Flash(this Controller controller, string message, FlashLevel level) { string key = String.Format("flash-{0}", level.ToString().ToLower()); var messages = (controller.TempData.ContainsKey(key)) ? (IList<string>)controller.TempData[key] : new List<string>(); messages.Add(message); controller.TempData[key] = messages; }
private static void AddMessage(Controller controller, string message, FlashLevel level) { var key = $"flash-{level.ToString().ToLower()}"; var messages = controller.TempData.ContainsKey(key) ? (IList <string>)controller.TempData[key] : new List <string>(); messages.Add(message); controller.TempData[key] = messages; }
public static void Flash(this Controller controller, string message, FlashLevel level) { IList <string> messages = null; string key = String.Format("flash-{0}", level.ToString().ToLower()); messages = (controller.TempData.ContainsKey(key)) ? (IList <string>)controller.TempData[key] : new List <string>(); messages.Add(message); controller.TempData[key] = messages; }