public static bool Register() { ICollection <User> users = DBUser.ReadUsers(); ConsoleUI.ShowLine("press 0 anytime to exit"); bool exit; exit = ConsoleUI.GetString(out string username, "give username: "******"give password: "******"repeat password: "******"passwords are not the same!!"); return(false); } string encryptedPassword = CryptoManager.EncryptPassword(password1, out string encryptedSalt); try { int headMasterSaved = DBUser.CreateUser(username, encryptedPassword, encryptedSalt, "headmaster", out int id); if (headMasterSaved == 0) { throw new Exception("head master NOT saved"); } } catch (Exception e) { ConsoleUI.ShowLine(e.Message); ConsoleUI.ReadKey(); return(false); } ConsoleUI.ShowLine("head master created"); ConsoleUI.ReadKey(); return(true); }
public static bool IsEmptyDB() { int UserSize = DBUser.ReadUsers().Count(); int AssignmentSize = DBAssignment.ReadAssignments().Count(); int StudentSize = DBStudent.ReadStudents().Count(); int CourseSize = DBCourse.ReadCourses().Count(); int TrainerSize = DBTrainer.ReadTrainers().Count(); bool basicEntities = UserSize == 0 && AssignmentSize == 0 && StudentSize == 0 && CourseSize == 0 && TrainerSize == 0; return(basicEntities); }
public static bool Login(out bool loggedIn, out string role, out int id) { ConsoleUI.ShowLine("press 0 anytime to exit"); bool exit; loggedIn = false; role = ""; id = -1; exit = ConsoleUI.GetString(out string username, "give username: "******"give password: "******"wrong credentials"); return(true); } }
public static bool HeadMasterExists() { ICollection <User> users = DBUser.ReadUsers(); return(users.Where(u => u.Role == "headmaster").Count() != 0); }