public UserProperties(User currentUser, string username)
        {
            InitializeComponent();
            this.User = currentUser;

            Username = username;

            var service = new SupportService(currentUser);

            if (string.IsNullOrEmpty(username))
            {
                _model = new BiolinkUserViewModel(new BiolinkUser());
                _isNew = true;
            }
            else
            {
                _model = new BiolinkUserViewModel(service.GetUser(username));
                txtUsername.IsReadOnly = true;
                btnOk.IsEnabled        = false;
                _model.DataChanged    += new DataChangedHandler(_model_DataChanged);
            }

            var groups = service.GetGroups().Select((m) => {
                var vm = new GroupViewModel(m);
                if (vm.GroupID == _model.GroupID)
                {
                    _model.Group = vm;
                }
                return(vm);
            });

            cmbGroup.ItemsSource = groups;

            this.DataContext = _model;
        }
        private bool ValidateUser(BiolinkUserViewModel model, bool isNew)
        {
            if (model.GroupID == 0)
            {
                ErrorMessage.Show("Please select a group before continuing");
                return(false);
            }

            if (string.IsNullOrEmpty(model.UserName))
            {
                ErrorMessage.Show("You must supply a username");
                return(false);
            }

            if (isNew || !string.IsNullOrEmpty(txtPassword.Password))
            {
                if (string.IsNullOrEmpty(txtPassword.Password))
                {
                    ErrorMessage.Show("Please supply a password");
                    return(false);
                }

                if (!txtPassword.Password.Equals(txtConfirmPassword.Password))
                {
                    ErrorMessage.Show("The password and the password confirmation do not match!");
                    return(false);
                }
            }

            return(true);
        }