public void Create(User user)
        {
            // HACK: should be using database-side value generation?
            user.Created = DateTime.UtcNow;

            using (var trans = Session.BeginTransaction())
            {
                Session.Save(user);
                trans.Commit();
            }
        }
        public ActionResult Edit(long id, User user)
        {
            ValidateUser(user);

            if (!ModelState.IsValid)
            {
                return View(user);
            }

            Users.Edit(id, user);
            return RedirectToAction("Index");
        }
        public void Edit(long id, User user)
        {
            using (var trans = Session.BeginTransaction())
            {
                var dbUser = Session.Get<User>(id);

                dbUser.OpenId = user.OpenId;
                dbUser.DisplayName = user.DisplayName;
                dbUser.Code = user.Code;
                dbUser.IsManager = user.IsManager;

                Session.Update(dbUser);
                trans.Commit();
            }
        }
        void ValidateUser(User user)
        {
            if (string.IsNullOrEmpty(user.DisplayName))
            {
                ModelState.AddModelError("Display Name", "Display name is required.", "");
            }

            if (!MvcHelpers.IsValidUri(user.OpenId))
            {
                ModelState.AddModelError("OpenId", "OpenId is not a valid URL.", "");
            }
        }