private void buttonSave_Click(object sender, EventArgs e)
        {
            client = db.Clients.Single(x => x.Id == client.Id);

            if (String.IsNullOrWhiteSpace(textBoxUsername.Text) ||
                String.IsNullOrWhiteSpace(textBoxPassword.Text) ||
                String.IsNullOrWhiteSpace(textBoxFirstName.Text) ||
                String.IsNullOrWhiteSpace(textBoxLastName.Text) ||
                String.IsNullOrWhiteSpace(textBoxEmail.Text))
            {
                MessageBox.Show("Fields can not be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TimeSpan span = DateTime.Today - dateTimePickerDateOfBirth.Value;
            double   dif  = span.Days / 365.25;

            if (dif < 18.00)
            {
                MessageBox.Show("you must be at least 18 years old", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (textBoxUsername.Text != client.Username)
            {
                if (ClientAccountValidator.CheckUsername(textBoxUsername.Text, db.Clients))
                {
                    MessageBox.Show("This username already exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            if (client.Email != textBoxEmail.Text)
            {
                if (ClientAccountValidator.CheckEmail(textBoxEmail.Text, db.Clients))
                {
                    MessageBox.Show("Inputed e-mail currently being used by other user", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            client.Username    = textBoxUsername.Text;
            client.Password    = textBoxPassword.Text;
            client.FirstName   = textBoxFirstName.Text;
            client.LastName    = textBoxLastName.Text;
            client.FullName    = textBoxFirstName.Text + " " + textBoxLastName.Text;
            client.DateOfBirth = dateTimePickerDateOfBirth.Value;

            if (ClientAccountValidator.ValidEmail(textBoxEmail.Text))
            {
                client.Email = textBoxEmail.Text;
            }
            else
            {
                MessageBox.Show("Input correct e-mail address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (profilePhotoByteArr == null)
            {
                MessageBox.Show("Select profile photo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            client.ProfilePhoto = profilePhotoByteArr;

            db.SaveChanges();
        }
        private void buttonCreateAccount_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(textBoxUsername.Text) ||
                String.IsNullOrWhiteSpace(textBoxPassword.Text) ||
                String.IsNullOrWhiteSpace(textBoxFirstName.Text) ||
                String.IsNullOrWhiteSpace(textBoxLastName.Text) ||
                String.IsNullOrWhiteSpace(textBoxEmail.Text))
            {
                MessageBox.Show("Fields can not be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TimeSpan span = DateTime.Today - dateTimePickerDateOfBirth.Value;
            double   dif  = span.Days / 365.25;

            if (dif < 18.0)
            {
                MessageBox.Show("You must be at least 18 years old", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ClientAccountValidator.CheckUsername(textBoxUsername.Text, db.Clients))
            {
                MessageBox.Show("This username already exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ClientAccountValidator.CheckEmail(textBoxEmail.Text, db.Clients))
            {
                MessageBox.Show("Inputed e-mail currently being used by other user", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Client client = new Client()
            {
                Username    = textBoxUsername.Text,
                Password    = textBoxPassword.Text,
                FirstName   = textBoxFirstName.Text,
                LastName    = textBoxLastName.Text,
                FullName    = textBoxFirstName.Text + " " + textBoxLastName.Text,
                DateOfBirth = dateTimePickerDateOfBirth.Value
            };

            if (ClientAccountValidator.ValidEmail(textBoxEmail.Text))
            {
                client.Email = textBoxEmail.Text;
            }
            else
            {
                MessageBox.Show("Input correct e-mail address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (profilePhotoByteArr == null)
            {
                MessageBox.Show("Select profile photo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (profilePhotoByteArr.GetUpperBound(0) < 1)
            {
                MessageBox.Show("Pick profile photo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            client.ProfilePhoto = profilePhotoByteArr;

            db.Clients.Add(client);
            db.SaveChanges();

            textBoxUsername.Text            = String.Empty;
            textBoxPassword.Text            = String.Empty;
            textBoxFirstName.Text           = String.Empty;
            textBoxLastName.Text            = String.Empty;
            textBoxEmail.Text               = String.Empty;
            profilePhotoByteArr             = null;
            pictureBoxProfilePhoto.Image    = null;
            dateTimePickerDateOfBirth.Value = DateTime.Today;
        }