public static void DeleteMessage() { Console.Write("Type the id of message you want to delete: "); int id; string ID = Console.ReadLine(); bool result = int.TryParse(ID, out id); DatabasesAccess da = new DatabasesAccess(); if (result) { bool MessageExist = HelpMethods.CheckExistMessage(id); if (MessageExist == true) { Console.Clear(); da.ProcessMessagesDatabase(id, "Delete_messages"); } else { HelpMethods.MessageDoesNotExist(); } } else { HelpMethods.IncorrectMessage(); } }
public static string RoleMenu() { while (true) { Console.WriteLine("ROLES MENU - Please choose an option."); Console.WriteLine("====================================="); Console.WriteLine("a. Set User"); Console.WriteLine("b. Set Admin with View Privilege"); Console.WriteLine("c. Set Admin with View and Edit Privilege"); Console.WriteLine("d. Set Admin with View, Edit and Delete Privilege"); Console.WriteLine("e. Set Super Admin"); Console.Write("\n"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Enter an option: "); Console.ForegroundColor = ConsoleColor.White; string key = Console.ReadLine(); if (roles.ContainsKey(key)) { Console.Clear(); return(roles[key]); } else { HelpMethods.IncorrectMessage(); } } }
public static void UserMenu() { Console.WriteLine("USER MENU - Please choose an option."); Console.WriteLine("===================================="); Console.WriteLine("a. Create new User"); Console.WriteLine("b. View Users"); Console.WriteLine("c. Delete Users"); Console.WriteLine("d. Update Username "); Console.WriteLine("e. Update Password"); Console.WriteLine("f. Update Role"); Console.Write("\n"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Enter an option: "); Console.ForegroundColor = ConsoleColor.White; string choice = Console.ReadLine(); if (editUser.ContainsKey(choice)) { Console.Clear(); editUser[choice](); } else { HelpMethods.IncorrectMessage(); } }
public static void EditMessage() { string cmd = "SELECT * FROM messages WHERE deleted = 0"; DatabasesAccess da = new DatabasesAccess(); IEnumerable <Message> messages = da.MessagesDatabase(cmd); Console.Write("Type the id of message you want to update: "); int id; string ID = Console.ReadLine(); bool result = int.TryParse(ID, out id); if (result) { bool MessageExist = HelpMethods.CheckExistMessage(id); if (MessageExist == true) { var senderId = messages .Where(x => x.id == id) .Select(x => x.senderId); int SenderId = Convert.ToInt32(senderId.FirstOrDefault()); var receiverId = messages .Where(x => x.id == id) .Select(x => x.receiverId); int ReceiverId = Convert.ToInt32(receiverId.FirstOrDefault()); da.ProcessMessagesDatabase(id, "Delete_messages"); Console.Clear(); Console.WriteLine($"Write the new message the maximun text limited to 250 characters"); Console.WriteLine("\n"); HelpMethods.SendMessage(SenderId, ReceiverId); } else { HelpMethods.MessageDoesNotExist(); } } else { HelpMethods.IncorrectMessage(); } }
public static void ApplicationMenu(User myUser) { Users user; Dictionary <string, Users> TypeOfUsers = new Dictionary <string, Users>() { { "User", new User(myUser.username, myUser.id) }, { "View Admin", new ViewAdmin(myUser.username, myUser.id) }, { "View-Edit Admin", new ViewEditAdmin(myUser.username, myUser.id) }, { "View-Edit-Delete Admin", new ViewEditDeleteAdmin(myUser.username, myUser.id) }, { "Super Admin", new SuperAdmin(myUser.username, myUser.id) } }; user = TypeOfUsers[myUser.role]; userId = user.id; Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"Welcome {myUser.username}"); Console.ForegroundColor = ConsoleColor.White; Console.Write("\n"); while (true) { user.PublicMenu(); Console.Write("\n"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Enter an option: "); Console.ForegroundColor = ConsoleColor.White; string choice = Console.ReadLine(); if (user.application.ContainsKey(choice)) { Console.Clear(); user.application[choice](); } else { HelpMethods.IncorrectMessage(); } } }
public static void ChatMenu() { Console.WriteLine("CHAT MENU - Please choose an option."); Console.WriteLine("===================================="); Console.WriteLine("a. Send Message"); Console.WriteLine("b. Read Messages"); Console.WriteLine("c. Read New Messages"); Console.WriteLine("d. Read All Messages"); Console.Write("\n"); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Enter an option: "); Console.ForegroundColor = ConsoleColor.White; string choice = Console.ReadLine(); if (menuMessages.ContainsKey(choice)) { Console.Clear(); menuMessages[choice](); } else { HelpMethods.IncorrectMessage(); } }