public void UpdateUser(User u)
 {
     var user = GetUserByUsername(u.username);
     user.first_name = u.first_name;
     user.last_name = u.last_name;
     user.email = u.email;
     user.phone = u.phone;
     db.SubmitChanges();
 }
 public void Add(User u)
 {
     db.Users.InsertOnSubmit(u);
     db.SubmitChanges();
 }
        void IAuthenticationManager.Register(User newUser)
        {
            if ( newUser == null )
            {
                throw new ArgumentNullException("newUser");
            }

            using (var transaction = _nhibernateSession.BeginTransaction())
            {
                if (Users.Any(u => u.Username.ToLowerInvariant() == newUser.Username.ToLowerInvariant()))
                {
                    throw new InvalidOperationException("Username already exists");
                }

                newUser.UserRoles.Add(_nhibernateSession.Load<Role>("User"));
                _nhibernateSession.Save(newUser);
                transaction.Commit();
            }
        }
 public void InsertUser(User user)
 {
     context.Users.Add(user);
 }
 public void UpdateUser(User user)
 {
     var tempUser = GetUserByID(user.Id);
     context.Entry<User>(tempUser).CurrentValues.SetValues(user);
     context.Entry<User>(tempUser).State = EntityState.Modified;
 }
        /// <summary>
        /// Creates initial data in the database
        /// </summary>
        /// <param name="factory"></param>
        private static void InsertInitialData(ISessionFactory factory)
        {
            using (var session = factory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    Role admin = new Role { RoleName = "Admin" };
                    Role manager = new Role { RoleName = "Manager" };
                    Role viewer = new Role { RoleName = "User" };

                    var nitzan =  new User
                    {
                        Id = 1,
                        Username = "******",
                        Password = "******",
                        Name = "Nitzan",
                        Email = "*****@*****.**"
                    }.AddRole(admin);

                    var shalom = new User
                    {
                        Id = 2,
                        Username = "******",
                        Password = "******",
                        Name = "Shalom",
                        Email = "*****@*****.**"
                    }.AddRole(manager);

                    var ofek = new User
                    {
                        Id = 3,
                        Username = "******",
                        Name = "Ofek",
                        Email = "*****@*****.**",
                        Password = "******"
                    }.AddRole(viewer);

                    session.Save(admin);
                    session.Save(manager);
                    session.Save(viewer);
                    session.Save(nitzan);
                    session.Save(shalom);
                    session.Save(ofek);

                    Article article = new Article
                    {
                       Header = "New Article For Testing",
                       PublishDate = DateTime.Now,
                       Publisher = nitzan,
                       Content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
                    };

                    ArticleComment comment = new ArticleComment
                    {
                        Comment = "This article sucks",
                        Commenter = shalom,
                        Header = "This article sucks",
                        PublishDate = DateTime.Now.AddHours(1)
                    };

                    article.AddComment(comment);
                    session.Save(article);
                    session.Save(comment);

                    transaction.Commit();
                }
            }
        }