static void Main() { var fastRun = false; var userrepository = new UserRepository(new ToyFactoryContext()); var users = userrepository.GetUsers(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (fastRun) { Application.Run(new Form1()); } else { if (users.Count > 0) { // run login Application.Run(new LoginForm(userrepository)); } else { //run registration form // Application.Run(new СreateUserForm(userrepository)); var form = new СreateUserForm(userrepository); form.ShowDialog(); users = userrepository.GetUsers(); if (users.Count > 0) { Application.Run(new LoginForm(userrepository)); } } } }
private void AddNewUserToolStripMenuItem_Click(object sender, EventArgs e) { Hide(); var createUserForm = new СreateUserForm(new UserRepository(_context)); createUserForm.ShowDialog(); ShowUserListDialog(); Show(); }