/* * return : * -4 if username allready exist in the system * 0 on success */ public int addUser(User newUser) { foreach (User u in users) { if (u.getUserName().Equals(newUser.getUserName())) { return(-4); } } newUser.setPassword(encrypt(newUser.getUserName() + newUser.getPassword())); UDB.Add(newUser); users.AddLast(newUser); return(0); }
public void addUser() { User toAdd = new User("itamar", "1a2b3c"); try { userDB.Add(toAdd); li = userDB.Get(); Assert.AreEqual(li.Count, 2); Assert.AreEqual(li.Last.Value.userName, "itamar"); Assert.AreEqual(li.Last.Value.getPassword(), "1a2b3c"); } catch (Exception e) { Assert.AreEqual(true, false, "there was a connection error to the testing db"); } }
public void init() { WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB(); cDB.emptyDB(); configuration.DB_MODE = testing; userDB = new UserDB(testing); userDB.Add(new User("aviad", "123")); li = new LinkedList <User>(); }
public ActionResult Create(User user) { if (ModelState.IsValid) { user.UserID = Guid.NewGuid(); UserDB.Add(user); UserDB.Commit(); return(RedirectToAction("Index")); } return(View(user)); }
private User CreateNewUser(dynamic me) { User new_user = new User(me.first_name, me.last_name, me.email); UserDB.Add(new_user); UserDB.Commit(); Locker new_locker = new Locker(new_user.UserID); LockerDB.Add(new_locker); LockerDB.Commit(); new_user.locker = new_locker; UserDB.Attach(new_user); UserDB.Commit(); return(new_user); }
public void Test_Test() { var db = new UserDB(); User result = null; for (int i = 0; i < 30; i++) { result = db.Add(new User() { Id = "TestId-" + DateTime.Now.ToString("yyMMddHHmmss"), Name = "Test-" + DateTime.Now.ToString("yyMMddHHmmss"), NickName = "NickName", Email = "*****@*****.**", Password = "******", CreatedTime = DateTime.Now }); Thread.Sleep(1000); } Assert.IsNotNull(result); }
public JsonResult Add(User usr) { return(Json(db.Add(usr), JsonRequestBehavior.AllowGet)); }
/// <summary> /// Create default admin and employee users and add them to the User repository. /// </summary> public void CreateDefaultUsers() { UserDB.Add(new User("admin", "", "*****@*****.**", "test", Permissions.Admin)); UserDB.Add(new User("employee", "", "*****@*****.**", "test", Permissions.Employee)); }
public void DoWork(User user) { userDb.Add(user); }
public void Register(UserAccount user) { user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(user.Password, "sha1"); UserDB.Add(user); SaveChanges(); }
/// <summary> /// 创建用户 /// </summary> /// <param name="user"></param> public int Add(Sys_User user) { _userDB.Add(user); return(user.UserId); }