Esempio n. 1
0
 public void Save()
 {
     User user = new User();
     user.Name = "sdfsdf";
     user.Age = 33;
     user.Password = "******";
     user.Username = "******";
     Console.Write("Calling FLuent");
     FluentDal dal = new FluentDal();
     dal.MakeConnnection();
     //       Hdal dal = new Hdal();
     //       dal.MakeConnection(user);
 }
Esempio n. 2
0
        public void MakeConnection(User user)
        {
            NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
               config.Configure().Configure("hibernate.cfg.xml");
               config.AddAssembly(typeof(User).Assembly);

               NHibernate.ISessionFactory factory = config.BuildSessionFactory();
               NHibernate.ISession session = factory.OpenSession();
             //    NHibernate.ITransaction transaction = session.BeginTransaction();
               /*      Console.Write("Saving");
               session.Save(user);   */

               IQuery iquery = session.CreateQuery("from User u where u.Username='******'");
               IList<User> returnUser = iquery.List<User>();
               Console.Write(returnUser[0].Age);

            //         transaction.Commit();
               session.Close();
        }
Esempio n. 3
0
        //       [TestMethod]
        public void TestUserDal()
        {
            UserDal uDal = new UserDal();

            User user = new User();

            user.Username = "******";
            user.Password = "******";

            User u = uDal.ValidateUser(user);
            IList<Membership> membership = u.Memberships;
            IList<Role> role = u.Roles;
            IList<Token> token = role[0].Tokens;

            Membership m = membership[0];
            Role r = role[0];
            Token t = token[0];

            Console.WriteLine("Membership : "+m.Name);
            Console.WriteLine("Role : "+r.Name);
            Console.WriteLine("Token : "+t.Name);

            //      Assert.AreEqual(1,uDal.Create(user));
        }
Esempio n. 4
0
 public UserBookRequest()
 {
     BookRequest = new BookRequest();
     User = new User();
     CreatedDateTime = DateTime.Now.ToString();
 }
Esempio n. 5
0
        public User ValidateUser(User user)
        {
            String query = "from User u where u.Username='******' " +
                           "and u.Password='******'";
            try
            {
                IDal<User> dal = new Dal<User>();

                IList<User> objectList = dal.Read(query);

                if (objectList.Count != 0)
                {
                    User returnedUser = (User) objectList.FirstOrDefault();
                    return returnedUser;
                }
                else
                {
                    return null;
                }
            }

            catch (Exception e)
            {
                Console.Write("Error at UserDal");
                Console.Write(e.ToString());
                return null;
            }
        }