public AddNewEmployeeViewModel(IAddNewEmployeeView view, IBusinessLogic logic) { this._businessLogic = logic; this._view = view; this._view.SetViewModel(this); try { UsersList = _businessLogic.GetAllUsers().OrderBy(d => d.Abbreviation).ToList(); } catch (Exception ex) { _view.Alert(ex.Message, "Error"); } }
public void AddNewEmployee(IAddNewEmployeeView inForm, IUserRepository userRepository) { if (inForm.ShowViewModal()) { try { string username = inForm.Username; string password = inForm.Password; User newEmployee = UserFactory.CreateUser(username, password, userRepository.GetRoleByName("Employee")); userRepository.AddEmployee(newEmployee); } catch (Exception ex) { MessageBox.Show("EXCEPTION: " + ex.Message); throw; } } }