static void Main(string[] args) { //using (var context = new SchoolDBDataContext()) //{ // context.UserAccounts.ToList().ForEach(ua => // { // var salt = BCrypt.Net.BCrypt.GenerateSalt(); // ua.Password = BCrypt.Net.BCrypt.HashPassword(ua.Password, salt); // }); // context.SubmitChanges(); //} bool continueLogin = true; do { int?userId = LoginView.Login(); int?roleId = 0; using (var context = new SchoolDBDataContext()) { roleId = context.UserAccounts.Where(ua => ua.User_ID == userId).Single().Role_ID; } LoginView.RoleChoice(roleId, userId); continueLogin = LoginView.LoginAgain(); } while (continueLogin); }
public void PrintDailySchedule() { using (var context = new SchoolDBDataContext()) { var courseDailySchedules = context.WeekDays.Select(wd => new { Day = wd, TimeInterval = wd.CourseWeekDays.Where(cw => cw.Course == this).Select(cw => cw.TimeInterval).FirstOrDefault() }); Console.WriteLine($"======== Course[{this.ID}] {this.Title} Daily Schedule ======== "); foreach (var ds in courseDailySchedules) { var start = "N/A"; var end = "N/A"; if (ds.TimeInterval != null) { start = ds.TimeInterval.StartTime; end = ds.TimeInterval.EndTime; } Console.WriteLine($"[{ds.Day.ID}]{String.Format("{0, -10}", ds.Day.Name + ":")} {start} - {end}"); } } }
public static void ReadPersonalAssignments(int userId) { using (var context = new SchoolDBDataContext()) { try { var student = context.Students.SingleOrDefault(s => s.ID == userId); if (student != null) { student.StudentAssignments.ToList().ForEach(sa => { Console.WriteLine(sa); Console.WriteLine(); }); } else { throw new InvalidOperationException("Invalid student Id"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public static int?Login() { Console.WriteLine("Welcome to School Management Portal"); bool successfullLogin = false; int? userId = 0; do { Console.WriteLine("Enter Username and Password to Login"); Console.Write("Username : "******"Password : "******"Hello {userInfo.FirstName} {userInfo.LastName}"); } else { Console.WriteLine("Incorrect username or password, please try again."); } } } while (successfullLogin == false); return(userId); //var userAccount = new userAccount(); //userAccount.UserName = usernameInserted; //userAccount.Password = passwordInserted; //////metatrepei to pass ayto paei stin vasi kanonika //var hashedpass = BCrypt.Net.BCrypt.HashPassword(passwordInserted); //Console.WriteLine(hashedpass); //////ckekarei to pass apo tin vasi //bool validpass = BCrypt.Net.BCrypt.Verify(passwordInserted, hashedpass); //Console.WriteLine(validpass); }
public static void SubmitAssignment(int userId) { using (var context = new SchoolDBDataContext()) { try { var student = context.Students.SingleOrDefault(s => s.ID == userId); if (student != null) { IIdentity courseAsIdentity = null; IIdentity assignmentAsIdentity = null; var studentCourses = student.StudentCourses.Select(sc => sc.Course); Console.WriteLine("======== Your Enrollments ========"); studentCourses.ToList().ForEach(c => Console.WriteLine(c)); while (!AdminView.TryGetEntityFromUserInput(studentCourses, "course", out courseAsIdentity)) { ; } var selectedCourse = (Course)courseAsIdentity; Console.WriteLine(); Console.WriteLine($"===== Assignments of Course[{selectedCourse.ID}] {selectedCourse.Title} ========"); var assignments = selectedCourse.Assignments; assignments.ToList().ForEach(a => Console.WriteLine(a)); while (!AdminView.TryGetEntityFromUserInput(assignments, "assignment", out assignmentAsIdentity)) { ; } } else { throw new InvalidOperationException("Invalid student Id"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public static void ReadSchedulePerCourse(int userId) { using (var context = new SchoolDBDataContext()) { try { var student = context.Students.SingleOrDefault(s => s.ID == userId); if (student != null) { Console.WriteLine($"======== Daily Schedule Per Course ========"); student.StudentCourses.Select(sc => sc.Course).ToList().ForEach(c => c.PrintDailySchedule()); } else { throw new InvalidOperationException("Invalid student Id"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }