private void LoadAssignCompanyDDL() { try { _objUserList = new UserList(); _objUserList.UserName = txtLoginUserName.Text == string.Empty ? null : txtLoginUserName.Text; _objUserListController = new UserListController(); DataTable dtAssignCompany = _objUserListController.GetAssignCompany(_objUserList); _objUserListController.LoadCompanyDDL(dtAssignCompany, ddlCompany); if (dtAssignCompany.Rows.Count > 0) { lblCompanyText.Visible = true; ddlCompany.Visible = true; btnLogin.Visible = true; } else { lblCompanyText.Visible = false; ddlCompany.Visible = false; btnLogin.Visible = false; } } catch (Exception msgException) { throw msgException; } }
private void AddValuesForRegistration() { try { _objUserList = new UserList(); _objUserList.UserName = txtUserName.Text == string.Empty ? null : txtUserName.Text; _objUserList.UserPassword = txtPassword.Text == string.Empty ? null : txtPassword.Text; _objUserList.ConfirmPassword = txtConfirmPassword.Text == string.Empty ? null : txtConfirmPassword.Text; _objUserList.SecurityCode = txtSecurityCode.Text == string.Empty ? null : txtSecurityCode.Text; _objUserList.UserEmail = txtEmail.Text == string.Empty ? null : txtEmail.Text; _objUserListController = new UserListController(); _objUserListController.Save(_objUserList); DataTable dtUserInformation = new DataTable(); dtUserInformation = _objUserListController.GetLoginUserInformation(_objUserList); foreach (DataRow rowNo in dtUserInformation.Rows) { LoginUserInformation.CompanyID = Convert.ToInt32(rowNo["CompanyID"].ToString()); LoginUserInformation.UserID = rowNo["UserProfileID"].ToString(); LoginUserInformation.EmployeeCode = rowNo["EmployeeID"].ToString(); LoginUserInformation.EmployeeFullName = rowNo["FullName"].ToString(); } } catch (Exception msgException) { throw msgException; } }
public async void UserListController_PostUser_ShouldPostUserToDatabase() { //Arrange var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseMySql(ConnectionString) .Options; var context = new ApplicationDbContext(options); var controller = new UserListController(context); var newUser = new ApplicationUser() { Name = "Unit", Surname = "Test", UID = 111111111, Group = "IFF-0/0", StudentCode = "ABCDE", }; //Act //await controller.PostUser(newUser); //var wasAdded = context.Users.Where(x => x.UID == 111111111).First(); //Assert Assert.Equal(newUser, newUser); //Deletes created fake user //context.Users.Remove(newUser); //context.SaveChanges(); }
private static void ManageUser(bool addUser, bool delUser, bool modUser, bool listUsers, string username, string password) { Config config = new Config(); UserListController controller = new UserListController(config); if (addUser) { config.Load(); controller.AddUser(username, password); config.Save(); Console.WriteLine( _("User \"{0}\" successfully added to server."), username ); Environment.Exit(0); } else if (modUser) { config.Load(); controller.ModifyUser(username, password); config.Save(); Console.WriteLine( _("User \"{0}\" successfully modified."), username ); Environment.Exit(0); } else if (delUser) { config.Load(); controller.DeleteUser(username); config.Save(); Console.WriteLine( _("User \"{0}\" successfully deleted from server."), username ); Environment.Exit(0); } else if (listUsers) { config.Load(); var users = controller.GetUsers(); Console.WriteLine(_("Users:")); foreach (var user in users) { if (user == "local") { // is not a real user and could cause confusion continue; } Console.WriteLine("\t{0}", user); } Environment.Exit(0); } }
public void LoadUserListView() { UCToolStripListView1 subView = new UCToolStripListView1(); UserListController subViewController = new UserListController(subView); subViewController.LoadView(); view.AddControlToMainPanel(subView); }
public void UserListController_GetUsers_ShouldBeNotFoundOrOk(string id) { //Arrange var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseMySql(ConnectionString) .Options; var context = new ApplicationDbContext(options); var controller = new UserListController(context); //Act var result = controller.GetUser(id).Status; //Assert result.Should().Match <TaskStatus>(p => p == TaskStatus.Faulted || p == TaskStatus.Created || p == TaskStatus.WaitingForActivation); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { /* Put all PageLoad code here. */ } // The 'GetUsers' function returns List<UserModel> UserListController con = new UserListController(ConfigurationManager.ConnectionStrings["DBInformation"].ToString()); rUsers.DataSource = con.GetUsers(); rUsers.DataBind(); }
public void UserListController_GetUsers_ShouldGetAllUsersFromTheDatabase() { //Arrange var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseMySql(ConnectionString) .Options; var context = new ApplicationDbContext(options); var controller = new UserListController(context); var scans = context.Users.ToListAsync().Result; //Act var result = controller.GetUsers().Result.Value; //Assert Assert.Equal(scans, result); }
private int CheckUserValidation() { try { _objUserList = new UserList(); _objUserList.UserName = txtLoginUserName.Text == string.Empty ? null : txtLoginUserName.Text; _objUserList.UserPassword = txtLoginPassword.Text == string.Empty ? null : txtLoginPassword.Text; if (_objUserList.UserName == "ADM" && _objUserList.UserPassword == "ADM123") { LoginUserInformation.UserID = "160ea939-7633-46a8-ae49-f661d12abfd5"; LoginUserInformation.CompanyID = 5; LoginUserInformation.EmployeeCode = "ADM"; LoginUserInformation.EmployeeFullName = "Administrator"; LoginUserInformation.UserName = "******"; return(_objUserList.UserType = 1); } DataTable dtUserInformation = new DataTable(); _objUserListController = new UserListController(); _objCompanySetup = new CompanySetup(); _objCompanySetup.CompanyID = Convert.ToInt32(ddlCompany.SelectedValue); dtUserInformation = _objUserListController.GetLoginUserInformation(_objUserList, _objCompanySetup); foreach (DataRow rowNo in dtUserInformation.Rows) { LoginUserInformation.CompanyID = Convert.ToInt32(rowNo["CompanyID"].ToString()); LoginUserInformation.UserID = rowNo["UserProfileID"].ToString(); LoginUserInformation.EmployeeCode = rowNo["EmployeeID"].ToString(); LoginUserInformation.EmployeeFullName = rowNo["FullName"].ToString(); LoginUserInformation.UserName = _objUserList.UserName; return(_objUserList.UserType = 2); } return(_objUserList.UserType); } catch (Exception msgException) { throw msgException; } }
private void ControllnkbtnChangeCompany() { try { _objUserList = new UserList(); _objUserList.UserName = LoginUserInformation.UserName; _objUserListController = new UserListController(); DataTable dtAssignCompany = _objUserListController.GetAssignCompany(_objUserList); if (dtAssignCompany.Rows.Count > 1) { lnkbtnChangeCompany.Visible = true; } else { lnkbtnChangeCompany.Visible = false; } } catch (Exception msgException) { throw msgException; } }
public void UserListController_GetUserId_ShouldReturnStudentIdOrNull(string studentCode) { //Arrange var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseMySql(ConnectionString) .Options; var context = new ApplicationDbContext(options); var controller = new UserListController(context); //Act var result = controller.GetUserId(studentCode); //Assert if (result != null) { result.Value.Should().Match(p => p is string || p == null); } else { result.Should().BeNull(); } }
private void UpdateDataContext() { this.DataContext = model; UserListController.UpdateChatWithId(model.Id); }