Esempio n. 1
0
        private void edytujKontoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AccountEditForm accountEditionForm = new AccountEditForm(this);

            accountEditionForm.Show();
        }
        static public void editAccount(AccountEditForm form, string email, string height, string weight, string aboutMe, bool permissionsChecked)
        {
            string _operation = "";

            var currEmail  = LoggedUserUtility.getCurrentEmail();
            var user       = db.uzytkownik.FirstOrDefault(uz => uz.login == currEmail);
            var contestant = db.zawodnik.FirstOrDefault(zaw => zaw.id_uzytkownik == user.id_uzytkownik);

            if (IsValidEmail(email))
            {
                user.login = email;
                LoggedUserUtility.setCurrentEmail(email);
                _operation += "\n- email";
            }
            else if (email.Length > 0)
            {
                MessageBox.Show("Zły format adresu email", "Niepowodzenie");
            }

            if (isNumber(height))
            {
                contestant.wzrost = int.Parse(height);
                _operation       += "\n- wzrost";
            }
            else if (height.Length > 0)
            {
                MessageBox.Show("Błąd w podanym wzroście", "Niepowodzenie");
            }

            if (isNumber(weight))
            {
                contestant.waga = int.Parse(weight);
                _operation     += "\n- waga";
            }
            else if (weight.Length > 0)
            {
                MessageBox.Show("Błąd w podanej wadze", "Niepowodzenie");
            }

            if (aboutMe.Length > 0)
            {
                contestant.o_sobie = aboutMe;
                _operation        += "\n- osiagniecia";
            }

            var previousPermissions = contestant.publiczne;

            contestant.publiczne = Convert.ToInt16(permissionsChecked);
            if (previousPermissions != Convert.ToInt16(permissionsChecked))
            {
                _operation += "\n- ustawienia prywatności";
            }
            db.SaveChanges();


            if (_operation.Length == 0)
            {
                MessageBox.Show("Nie edytowano żadnych danych", "Brak zmian");
            }
            else
            {
                MessageBox.Show("Z powodzeniem edytowano: " + _operation, "Powodzenie");
            }
            form.Close();
        }