public Models.User Create(string name, string paasword, string email, bool enabled) { if ((DBUser.name == name).Count <DBUser>(DB) > 0) { return(null); } DBUser user = new DBUser(); user.Name = name; user.Password = paasword; user.Email = email; user.Enabled = enabled; user.Save(DB); return(user.MemberCopyTo <Models.User>()); }
public void DeleteUserTest() { using (DBUser dbUser = new DBUser()) { User user = new User(); dbUser.Connection = new MySqlConnection(connString); dbUser.Connection.Open(); user.Name = "TestDelete"; user.Password = "******"; user.Group = 1; Assert.IsTrue(dbUser.Save(user)); int lastID = (int)dbUser.LastID; dbUser.Load(lastID); Assert.IsNotNull(dbUser.BusinessObject); dbUser.Delete(); dbUser.Load(lastID); Assert.IsNull(dbUser.BusinessObject); Assert.IsTrue(dbUser.Save(user)); lastID = (int)dbUser.LastID; dbUser.Delete(lastID); dbUser.Load(lastID); Assert.IsNull(dbUser.BusinessObject); } }