private void SetInputs()
        {
            txNewFirstPassword.Value = EditedUser != null ? EditedUser.Password : string.Empty;
            txNewUserName.Value      = EditedUser != null ? EditedUser.UserName : string.Empty;
            txDisplay.Value          = EditedUser != null ? EditedUser.DisplayName : string.Empty;

            foreach (GridViewRow gvr in gvClientPagePermissions.Rows)
            {
                int pageid = int.Parse(((HiddenField)gvr.FindControl("hfpid")).Value);
                ((CheckBox)gvr.FindControl("chk")).Checked = EditedUser != null && EditedUser.AllowedClientPagePermissions.Contains((ClientPagePermissions)pageid);
            }
            btnAddUser.InnerText   = EditedUser != null ? "עדכן" : "הוסף";
            cmbusers.SelectedValue = EditedUser != null?EditedUser.Id.ToString() : "-1";

            UserGoogleApiData apiData = new UserGoogleApiData();

            if (EditedUser != null)
            {
                apiData = GetUserGoogleApiData(EditedUser.Id);
            }

            txClientId.Value     = EditedUser != null ? apiData.installed.client_id : string.Empty;
            TxClientSecret.Value = EditedUser != null ? apiData.installed.client_secret : string.Empty;
            txProjectId.Value    = EditedUser != null ? apiData.installed.project_id : string.Empty;
        }
 private static void LoadApiSettings()
 {
     googleApiData = db.DbGenericData.GetGenericData <UserGoogleApiData>(new GoogleApDataSearchParameters {
         UserId = uId
     }).FirstOrDefault() ??
                     new UserGoogleApiData();
 }
        protected void btnAddUser_ServerClick(object sender, EventArgs e)
        {
            bool newUser = EditedUser == null;

            if (newUser)
            {
                EditedUser = new LoggedUser();
            }

            if (ValidateInputs(txNewUserName))
            {
                EditedUser.UserName    = txNewUserName.Value;
                EditedUser.Password    = txNewFirstPassword.Value;
                EditedUser.DisplayName = txDisplay.Value;
                EditedUser.AllowedClientPagePermissions = new List <ClientPagePermissions>();
                foreach (GridViewRow gvr in gvClientPagePermissions.Rows)
                {
                    if (((CheckBox)gvr.FindControl("chk")).Checked)
                    {
                        int pageid = int.Parse(((HiddenField)gvr.FindControl("hfpid")).Value);
                        EditedUser.AllowedClientPagePermissions.Add((ClientPagePermissions)pageid);
                    }
                }

                if (newUser)
                {
                    DBController.DbAuth.Add(EditedUser);
                }
                else
                {
                    DBController.DbAuth.Update(EditedUser); // edit !!!!!!
                }
                if (ValidateInputs(txProjectId, TxClientSecret, txClientId) && !newUser)
                {
                    UserGoogleApiData apiData = GetUserGoogleApiData(EditedUser.Id);
                    apiData.installed.project_id    = txProjectId.Value;
                    apiData.installed.client_secret = TxClientSecret.Value;
                    apiData.installed.client_id     = txClientId.Value;
                    apiData.UserId = EditedUser.Id;
                    if (apiData.Id > 0)
                    {
                        DBController.DbGenericData.Update(apiData);
                    }
                    else
                    {
                        DBController.DbGenericData.Add(apiData);
                    }
                }
                EditedUser = null;
                SetInputs();
                AlertMessage("פעולה זו בוצעה בהצלחה");
            }
            else
            {
                AlertMessage("אחד או יותר מהשדות ריקים");
            }
        }