Ejemplo n.º 1
0
        public void AddUser(User user)
        {
            user.DateAdded = DateTime.UtcNow;

            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                session.Store(user);
                session.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public User GetUser(int id)
        {
            User user = new User();

            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                user = session.Query<User>().Where(u => u.Id == id).SingleOrDefault();
            }

            return user;
        }
Ejemplo n.º 3
0
        public void EditUser(User user)
        {
            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                User editedUser = session.Load<User>
                    (string.Format("users/{0}", user.Id.ToString()));

                editedUser.Email = user.Email;
                editedUser.DisplayName = user.DisplayName;
                editedUser.Biography = user.Biography;

                session.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public bool ValidateUser(string username, string password)
        {
            User user = new User();

            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                user = session.Query<User>().Where(u => u.Username == username).SingleOrDefault();
            }

            if (user == null)
                return false;
            if (user.Password == Util.HashString(password))
                return true;
            else
                return false;
        }
Ejemplo n.º 5
0
        public string GetValidationCode(string username)
        {
            User user = new User();

            using (IDocumentSession session = HawramanApplication.RavenDbDocumentStore.OpenSession())
            {
                user = session.Query<User>().Where(u => u.Username == username).SingleOrDefault();
            }

            return user.VerificationCode;
        }