public static Teacher CopyToTeacher(User user) { return new Teacher { Id = user.Id, Name = user.Name, Email = user.Email, Address = user.Address, PostCode = user.PostCode, Phone = user.Phone, Type = user.Type, Payrole = 0 }; }
public EditViewModel(User Editing_User) { if (Editing_User.Type == (int)User.User_Type.Student) { Student Current = Student.CopyToStudents(Editing_User); Current.GetUser_ByEmail(); this.Editing_User = Current; } else if (Editing_User.Type == (int)User.User_Type.Teacher) { Teacher Current = Teacher.CopyToTeacher(Editing_User); Current.GetUser_ByEmail(); this.Editing_User = Current; } this.View = new EditView(); }
public static Student CopyToStudents(User user) { string dateTime = DateTime.Now.ToString("yyyy-MM-dd"); DateTime Time = DateTime.Parse(dateTime); return new Student { Id = user.Id, Name = user.Name, Email = user.Email, Address = user.Address, PostCode = user.PostCode, Phone = user.Phone, Type = user.Type, Education_StartDate = Time, Education_EndDate = Time }; }
public LoginViewModel() { LoginUser = new User(); this.View = new MainLoginView(); }
private void Registradet(object sender, User NewUser) { LoginUser = NewUser; ((BaseViewModel)sender).Dispose(); Login(); }
private void Register() { if (!String.IsNullOrEmpty(UserEmail)) { try { LoginUser.GetUser_ByEmail(); ErrorText = "User already exists"; ErrorActive = true; LoginUser = new User(); } catch (ArgumentNullException ex) { if (ex.Message.Equals("User does not exists\r\nParameter name: Get User info fail")) { ViewWindow RegisterWindow; BaseViewModel RegisterWindow_ViewModel; RegisterWindow = new ViewWindow(); RegisterWindow_ViewModel = new RegisterViewModel(LoginUser); ((RegisterViewModel)RegisterWindow_ViewModel).OnUserRegistrated += Registradet; RegisterWindow_ViewModel.ShowInWindow(RegisterWindow); } else { ErrorText = ex.Message; ErrorActive = true; } } catch (Exception ex) { ErrorText = ex.Message; ErrorActive = true; } } else { ErrorText = "Missing email"; ErrorActive = true; } }
public RegisterViewModel(User Register_User) { RegistrateUser = Register_User; UserType = User.User_Type.Student; this.View = new RegisterView(); }
private void User_Login(object sender, User Currentuser) { ((BaseViewModel)sender).Dispose(); CurrentUser = Currentuser; CurrentView = ViewModes.Editor; }
private void User_Edited(object sender, User Currentuser) { ((BaseViewModel)sender).Dispose(); CurrentView = ViewModes.Main; }
public MainControler() { CurrentUser = null; CurrentView = ViewModes.Main; ViewHandler(); }