public static async Task <List <PrivateLog> > GetAllLogData() { HttpResponseMessage response = await client.GetAsync(CreateQueryString(Properties.Resources.ProjectID, QueryType.GetAll, "logs")); if (response.IsSuccessStatusCode) { Debug.WriteLine("Successful"); string json = response.Content.ReadAsStringAsync().Result; Dictionary <string, PrivateLogDTO> data = JsonConvert.DeserializeObject <Dictionary <string, PrivateLogDTO> >(json); List <PrivateLog> logs = new List <PrivateLog>(); foreach (var item in data.Values.ToList()) { PrivateLog pl = new PrivateLog(item); pl.Message = Decrypt(pl.Message, Keys.PrivateKey); logs.Add(pl); } return(logs); } else { Debug.WriteLine("Unsuccessful"); return(null); } }
static void MenuOptions_GetLog() { Console.Write("Please enter ID of Log:"); string id = Console.ReadLine(); PrivateLog dto = JMS_Commands.GetLog(id); if (dto != null) { PrintLog(dto); } else { Console.WriteLine("No Results."); } }
static void MenuOptions_UpdateLog() { Console.Write("Please enter the id of the log item you would like to update:"); PrivateLog log = JMS_Commands.GetLog(Console.ReadLine()); Console.Write("Log to update:"); PrintLog(log); Console.Write("Please enter updated log message:"); log.Message = Console.ReadLine(); JMS_Commands.CreateLog(new PrivateLogDTO(log)); log = null; GC.Collect(); }
public static async Task <PrivateLog> GetLogData(string id) { HttpResponseMessage response = await client.GetAsync(CreateQueryString(Properties.Resources.ProjectID, QueryType.Get, "logs", id)); if (response.IsSuccessStatusCode) { Debug.WriteLine("Successful"); string json = response.Content.ReadAsStringAsync().Result; PrivateLogDTO data = JsonConvert.DeserializeObject <PrivateLogDTO>(json); PrivateLog log = new PrivateLog(data); log.Message = Decrypt(log.Message, Keys.PrivateKey); return(log); } else { Debug.WriteLine("Unsuccessful"); return(null); } }
public static void PrintLog(PrivateLog dto) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"ID:{dto.ID} - User ID:{dto.UserID} - Message:{dto.Message}"); Console.ForegroundColor = ConsoleColor.White; }
public void InvokePrivateLog(string message) => PrivateLog?.Invoke(new LogEvent(game, message));