public void Update(EditViewModel model, User user)
        {
            if (model.Id != user.Id)
            {
                throw new InvalidOperationException("Entity cannot be updated because of Id mismatch");
            }

            user.Username = model.Username;
            user.Password = model.Password.NotEmpty()
                ? model.Password.Md5Hash()
                : user.Password;
            user.IsAdministrator = model.IsAdministrator;
            user.Email = model.Email;
            user.Privileges = model.IsAdministrator
                ? new List<Privileges>()
                : _privilegesAssembler.ToEntities(model.Privileges);
        }
        public virtual ActionResult Edit(EditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return PartialView(model);
            }

            var user = Context.Users.Get(model.Id);
            if (user == null)
            {
                return RedirectToAction(MVC.Account.ActionNames.List);
            }

            _editAssembler.Update(model, user);
            Context.Users.Save(user);

            return RedirectWithMessage(MVC.Account.ActionNames.List, Strings.UserEditedMessage);
        }