public void AddUser_NewUsers_ReturnsNewUser() { SetupEmpty(); context.ClearDatabase(); bool user1added = userAccess.AddUser(firstUser, password) != null; bool user2added = userAccess.AddUser(secondUser, password) != null; bool user3added = userAccess.AddUser(thirdUser, password) != null; Assert.True(user1added); Assert.True(user2added); Assert.True(user3added); }
public string addUser(User aUser) { SqlParameter[] aSqlParameter = new SqlParameter[5]; aSqlParameter[0] = new SqlParameter("@UserName", SqlDbType.VarChar, 50); aSqlParameter[0].Value = aUser.UserName; aSqlParameter[1] = new SqlParameter("@Password", SqlDbType.VarChar, 50); aSqlParameter[1].Value = aUser.Password; aSqlParameter[2] = new SqlParameter("@Name", SqlDbType.VarChar, 50); aSqlParameter[2].Value = aUser.Name; aSqlParameter[3] = new SqlParameter("@Email", SqlDbType.VarChar, 50); aSqlParameter[3].Value = aUser.Email; aSqlParameter[4] = new SqlParameter("@UserType", SqlDbType.VarChar, 50); aSqlParameter[4].Value = "U"; int rowEffected = aUserDataAccess.AddUser(aSqlParameter); if (rowEffected > 0) { return("Save Successfuly"); } else { return("Register Failed "); } }
public void AddUser(string id, string name, Gender gender) { if (_userDal.IsUserExist(id)) { return; } _userDal.AddUser(id, name, gender); }
public void AddUser(User user) { if (_userDal.IsUserExist(user.UserName)) { return; } _userDal.AddUser(user); }
private void SetupEmpty() { context = new ChessAppTestingContext(); gameAccess = new GameDataAccess((IDbContext)context); userAccess = new UserDataAccess((IDbContext)context); playerWhite = new User(); playerWhite.Name = "playerWhite"; playerBlack = new User(); playerBlack.Name = "playerBlack"; password = "******"; context.ClearDatabase(); userAccess.AddUser(playerWhite, password); userAccess.AddUser(playerBlack, password); }
public ActionResult CreateUser(Users newuser) { //check if user is accessing view in web browser. if (ModelState.IsValid) { //states that any new acccount gats the user role. newuser.RoleID = 3; //Sends instance of User to the Uda through mapper UDA.AddUser(Umap.Map(newuser)); } return(RedirectToAction("Login")); }
/// <summary> /// Sends user info to DataAccess for user registration /// </summary> /// <param name="user"></param> /// <returns></returns> public bool AddUser(string identityNumber, string firstName, string lastName, string email, string phone, string password) { if (RegistrationValidationMessage(identityNumber, firstName, lastName, email, phone, password) == "Good") { //Generates a unique identifier Guid userGuid = Guid.NewGuid(); User newUser = new User(userGuid.ToString(), identityNumber, firstName, lastName, email, phone, HashPassword(password)); return(userDataAccess.AddUser(newUser)); } return(false); }
public ActionResult Register(UserViewModel viewModel) { if (ModelState.IsValid) { viewModel.SingleUser.Password = PasswordLogic.PasswordHash(viewModel.SingleUser.Password); viewModel.SingleUser.RoleID = 1; viewModel.SingleUser.TeamID = 1; viewModel.SingleUser.HeroID = 1; UserDataAccess.AddUser(Mapper.Map(viewModel.SingleUser)); } return RedirectToAction("Login", "User"); }
private void SetupFull() { context = new ChessAppTestingContext(); userAccess = new UserDataAccess((IDbContext)context); firstUser = new User(); firstUser.Name = "firstUser"; secondUser = new User(); secondUser.Name = "secondUser"; thirdUser = new User(); thirdUser.Name = "thirdUser"; password = "******"; context.ClearDatabase(); userAccess.AddUser(firstUser, password); userAccess.AddUser(secondUser, password); userAccess.AddUser(thirdUser, password); }
public void UserRegister(string name, string surname, string password, string mac_address_value) { JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Clear(); Context.Response.ContentType = "application/json"; Package package = new Package(); User user = new User(); if (password != name) { if (uda.GetUserId(name, surname) == -1) { int max_id = uda.GetLastId(); user.id = max_id + 1; user.name = name; user.surname = surname; user.password = password; user.authority_id = 2; MacAddress mac_address = new MacAddress(); int mac_max_id = mda.GetLastId(); mac_address.id = mac_max_id + 1; mac_address.value = mac_address_value; mac_address.user_id = max_id + 1; if (uda.AddUser(user).id != -1 && mda.AddMacAddress(mac_address).id != -1) { package.process_code = 1; } else { package.process_code = 20; } } else { package.process_code = 12; } } else { package.process_code = 19; } package.package_object = user; Context.Response.Write(js.Serialize(package)); }
public MainViewModel() { var personData = new PersonDataAccess(RepositoryFactory<Person>.GetRepository()); var companyData = new CompanyDataAccess(RepositoryFactory<Company>.GetRepository()); var invoiceData = new InvoiceDataAccess(RepositoryFactory<Invoice>.GetRepository(), RepositoryFactory<InvoiceRow>.GetRepository()); var userData = new UserDataAccess(RepositoryFactory<User>.GetRepository()); RegistratePersonViewModel = new RegistratePersonViewModel(personData); RegistrateCompanyViewModel = new RegistrateCompanyViewModel(companyData); RegisterInvoiceViewModel = new RegistrateInvoiceViewModel(invoiceData, companyData, personData); InvoiceViewModel = new InvoiceViewModel(invoiceData); userData.AddUser("admin", "admin"); LoginViewModel = new LoginViewModel(userData); }
public MainViewModel() { var personData = new PersonDataAccess(RepositoryFactory <Person> .GetRepository()); var companyData = new CompanyDataAccess(RepositoryFactory <Company> .GetRepository()); var invoiceData = new InvoiceDataAccess(RepositoryFactory <Invoice> .GetRepository(), RepositoryFactory <InvoiceRow> .GetRepository()); var userData = new UserDataAccess(RepositoryFactory <User> .GetRepository()); RegistratePersonViewModel = new RegistratePersonViewModel(personData); RegistrateCompanyViewModel = new RegistrateCompanyViewModel(companyData); RegisterInvoiceViewModel = new RegistrateInvoiceViewModel(invoiceData, companyData, personData); InvoiceViewModel = new InvoiceViewModel(invoiceData); userData.AddUser("admin", "admin"); LoginViewModel = new LoginViewModel(userData); }
public int AddNewUser(string firstName, string LastName, string email, string username, string password, string gender, string address, string bloodGroup, string organisationName, int govtLicenseNo, int userType) { User donor = new User() { FirstName = firstName, LastName = LastName, Email = email, Username = username, Password = password, Gender = gender, Address = address, BloodGroup = bloodGroup, OrganisationName = organisationName, GovtLicenseNo = govtLicenseNo, UserType = userType }; OrganisationService organisationService = new OrganisationService(); return(userDataAccess.AddUser(donor)); }
protected void btnSignUp_Click(object sender, EventArgs e) { User newUser = new User(); newUser.Name = txtName.Text.Trim(); newUser.Handle = txtUserName.Text.Trim(); newUser.Email = txtEmail.Text.Trim(); newUser.Address = txtAddress.Text.Trim(); string password = txtPassword.Text.Trim(); try { UserDataAccess userDB = new UserDataAccess(); userDB.AddUser(newUser, password); Response.Redirect("Login.aspx?NewSignUp=1"); } catch (Exception ex) { lblErrorMessage.Text = ex.Message; } }
public async Task <IActionResult> SignUp(SignUpViewModel model) { if (ModelState.IsValid) { User user = userDAL.GetUser(model.Email, null); if (user == null) { userDAL.AddUser(new User() { Email = model.Email, Surname = model.Surname, Name = model.Name, Password = model.Password }); await Authenticate(model.Email, "user"); return(PartialView("~/Views/Account/_SignUp.cshtml")); } else { return(Json(new { error = "This email has already registred in system" })); } } return(Json(new { error = "Passwords aren't matched" })); }
public ActionResult RegisterAction(string userNumber, string nickname, string password, string age, string subject) { UserDataAccess uda = new UserDataAccess(); bool isexist = uda.isUserExist(userNumber); if (isexist == false) { bool addsuccess = uda.AddUser(userNumber, nickname, password, age, subject); if (addsuccess) { return(Json("注册成功")); } else { return(Json("注册失败")); } } else { return(Json("该用户已注册")); } }
private async void Submit_Clicked(object sender, EventArgs e) { //We create new user here if (Password.Text == PasswordAgain.Text && Email.Text != null && Name.Text != null) { UserDataAccess = new UserDataAccess(); String text = ""; if (userPhoto == null) { text = "@drawable/defaultuser"; } else { text = userPhoto.Text; } user = new User { Email = Email.Text, Password = Password.Text, UserName = Name.Text, UserType = UserAdmin.User, UserPhoto = text }; int number = UserDataAccess.AddUser(user); if (number > 0) { await DisplayAlert("Sign Up", "Thanks for joining us " + Name.Text, "OK"); await Navigation.PopAsync(); } else { await DisplayAlert("Sign Up", "Didn't add " + Name.Text, "OK"); } await Navigation.PopAsync(); } }
public bool AddUser(User user) { return(dataAccess.AddUser(user)); }
public void AddUser(User user) { UserDataAccess.AddUser(user); }
public bool AddUser(string name, string phone, string email, string password, string role, string addedBy, string allowAssignTask, string userId) { UserDataAccess obj = new UserDataAccess(); return(obj.AddUser(name, phone, email, password, role, addedBy, allowAssignTask, userId)); }