예제 #1
0
        public void AddPermission(Account account, Permission permission)
        {
            var ap = new AccountPermission {
                                                AccountId = account.AccountId,
                                                Permission = permission
                                            };

            BeginTransaction();
            NHibernateSession.SaveOrUpdate(ap);
        }
예제 #2
0
        public void CreateDatabaseSchemaFluently()
        {
            Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString("server=.;trusted_connection=yes;database=cxromos"))
                .Mappings(x => x.FluentMappings.AddFromAssemblyOf<Account>())
                .ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true))
                .BuildSessionFactory();

            IAccountRepository accountRepository = new AccountRepository();

            const string email = "*****@*****.**";

            var account = new Account {
                FirstName = "ace",
                LastName = "xman",
                Username = "******",
                Email = email,
                Password = "******".Encrypt("ace"),
                CreateDate = DateTime.Now,
                LastUpdateDate = DateTime.Now,
                BirthDate = new DateTime(1974, 9, 6),
                EmailVerified = true
            };

            accountRepository.SaveAccount(account);
            accountRepository.CommitChanges();

            var permissions = new List<Permission> {
                                                       new Permission {Name = "PUBLIC"},
                                                       new Permission {Name = "ADMINISTRATOR"},
                                                       new Permission {Name = "MODERATOR"}
                                                   };

            BeginTransaction();
            foreach (var permission in permissions) {
                NHibernateSession.SaveOrUpdate(permission);
            }
            CommitChanges();

            var ap = new AccountPermission {
                                               AccountId = account.AccountId,
                                               Permission = permissions[0]
                                           };

            BeginTransaction();
            NHibernateSession.SaveOrUpdate(ap);
            CommitChanges();
        }
예제 #3
0
        public void AddAccountTest()
        {
            const string email = "*****@*****.**";

            var account = new Account {
                FirstName = "ace",
                LastName = "xman",
                Email = email,
                Password =
                Cryptography.Encrypt("ace", email.Split('@')[0]),
                CreateDate = DateTime.Now,
                LastUpdateDate = DateTime.Now,
                BirthDate = new DateTime(1974, 9, 6),
                EmailVerified = true
            };

            var key = "LyguPn/aTzJojVPOMfIZ1A+Q/C0c/7SNHI28Jj0xXWc=";
            var pass = key.Decrypt("danijel");
            Trace.Write(pass.ToString());
        }
예제 #4
0
 public void SaveAccount(Account account)
 {
     BeginTransaction();
     NHibernateSession.SaveOrUpdate(account);
 }
예제 #5
0
 public void DeleteAccount(Account account)
 {
     BeginTransaction();
     NHibernateSession.Delete(account);
 }
예제 #6
0
 public Navigation()
 {
     _usersSession = ObjectFactory.GetInstance<IUserSession>();
     _redirector = ObjectFactory.GetInstance<IRedirector>();
     _account = _usersSession.CurrentUser;
 }