Esempio n. 1
0
        public Guid CreateProfile(string username, string password, string email, string name, string surname)
        {
            Profile newProfile = new Profile();

            newProfile.Username = username;
            newProfile.Password = password;
            newProfile.Email = email;
            newProfile.Name = name;
            newProfile.Surname = surname;

            Repository.Add(newProfile);

            return newProfile.ID;
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="profile"></param>
        public Guid Add(Profile profile)
        {
            Guid guid = Guid.Empty;

            using (ISession session = NHibernateHelper.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    profile.CreatedOn = DateTime.Now;
                    profile.UpdatedOn = DateTime.Now;
                    guid = (Guid)session.Save(profile);
                    transaction.Commit();
                }
            }

            return guid;
        }
Esempio n. 3
0
 public void ModifyProfile(Profile profile)
 {
     Repository.Update(profile);
 }
Esempio n. 4
0
        public Guid AddProfile(Profile profile)
        {
            Repository.Add(profile);

            return profile.ID;
        }
        public void AddProfileTest()
        {
            Profile profile = new Profile()
            {
                Username = "******",
                Password = "******",
                Email = "*****@*****.**",
                Name = "Eric",
                Surname = "Banna",
                Gender = Gender.Male,
                Description = "Hi, I'm Hulk.",
                Address = new Address {
                    Street = "Sunset Boulevar",
                    City = "L.A",
                    PostalCode = "99999"
                }
            };

            IProfileRepository repo = new ProfileRepository();
            repo.Add(profile);

            using (ISession session = _sessionFactory.OpenSession())
            {
                var profileFromDB = session.Get<Profile>(profile.ID);

                Assert.IsNotNull(profileFromDB);
                Assert.AreNotSame(profile, profileFromDB);
                Assert.AreEqual(profile.Username, profileFromDB.Username);
                Assert.AreEqual(profile.Password, profileFromDB.Password);
                Assert.AreEqual(profile.Email, profileFromDB.Email);
                Assert.AreEqual(profile.Name, profileFromDB.Name);
                Assert.AreEqual(profile.Surname, profileFromDB.Surname);
                Assert.AreEqual(profile.Gender, profileFromDB.Gender);
                Assert.AreEqual(profile.Description, profileFromDB.Description);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="profile"></param>
 public void Update(Profile profile)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             profile.UpdatedOn = DateTime.Now;
             session.Update(profile);
             transaction.Commit();
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="profile"></param>
 public void Remove(Profile profile)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             session.Delete(profile);
             transaction.Commit();
         }
     }
 }