Esempio n. 1
0
        public void Find_ShouldFindTheRecordById()
        {
            var original = new Account();
            repository.Save(original);
            session.Clear();

            var record = repository.Find<Account>(1);
            Assert.IsTrue(record.Equals(original));
        }
Esempio n. 2
0
 public ActionResult Update(Account account)
 {
     if (ModelState.IsValid)
     {
         repository.Save(account);
         return RedirectToAction("Show", account.Id);
     }
     return View("Edit", account);
 }
Esempio n. 3
0
        public void FindAll_ShouldFindRecordsByCriteria()
        {
            var original = new Account();
            repository.Save(original);
            session.Clear();

            var record = repository.FindAll<Account>(x => x.Id == 1);
            Assert.IsTrue(record[0].Equals(original));
        }
Esempio n. 4
0
        public ActionResult Create(Account account)
        {
            if (ModelState.IsValid)
            {
                repository.Save(account);
                return RedirectToAction("Index");
            }

            return RedirectToAction("New");
        }
Esempio n. 5
0
        public Account Create(string email, string password)
        {
            var salt = GenerateSalt(40);
            var user = new Account
            {
                Email = email,
                EncryptedPassword = GenerateSaltedPassword(password, salt),
                PasswordSalt = salt
            };

            repository.Save(user);

            return user;
        }