public void InitialiseTest()
        {
            documentStore = new EmbeddableDocumentStore
            {
                RunInMemory = true
            };
            documentStore.Initialize();

            session = documentStore.OpenSession();
            var user1 = new User
            {
                FullName = "FullName1",
                Username = "******",
                Password = "******",
            };
            session.Store(user1);

            var user2 = new User
            {
                FullName = "FullName2",
                Username = "******",
                Password = "******",
            };
            session.Store(user2);
            session.SaveChanges();
        }
 public ActionResult SignIn(User user)
 {
     if (ValidateUser(user.Username,user.Password))
     {
         return RedirectToAction("Index", "Admin");
     }
     TempData["Error"] = string.Format("Invalid username or password !");
     return View();
 }
        public ActionResult Register(User user)
        {
            if (user == null)
                return View();

            if (_documentSession.Query<User>().FirstOrDefault(users => users.Username == user.Username) != null)
            {
                TempData["Error"] = string.Format("Username {0} already exists. Please choose another one! ", user.Username);
                return View();
            }

            user.ID = Guid.NewGuid();

            _documentSession.Store(user);
            _documentSession.SaveChanges();
            TempData["Success"] = string.Format("New user: {0}", user.FullName);

            return Redirect("/Home");
        }