コード例 #1
0
        void SaveDepartment(object sender, EventArgs e)
        {
            // Check of alle velden ingevuld zijn
            foreach (var element in addDepartmentStack.Children)
            {
                if (element is Entry entry)
                {
                    if (String.IsNullOrWhiteSpace(entry.Text) && entry.Placeholder.Contains("*"))
                    {
                        DisplayAlert("Alert", "Graag alle velden met een * invullen", "Ok");
                        return;
                    }
                }
                if (element is Picker picker)
                {
                    if (picker.SelectedItem == null)
                    {
                        DisplayAlert("Alert", "Graag een bedrijf selecteren", "Ok");
                        return;
                    }
                }
            }

            if (!InputValidationHelper.ValidateIban(addDepartmentBankNumber.Text))
            {
                DisplayAlert("Alert", "Graag een correcte IBAN invullen", "Ok");
                return;
            }

            if (!int.TryParse(addDepartmentCostCenterNumber.Text, out int result))
            {
                DisplayAlert("Alert", "Graag een correcte Kostenplaatsnummer invullen", "Ok");
                return;
            }

            department.BankaccountNumber = addDepartmentBankNumber.Text;
            department.CompanyId         = selectedCompany.CompanyId;
            department.DepartmentName    = addDepartmentDepartmentName.Text;

            Task.Run(async() =>
            {
                // If id is 0, it's a new entry...
                if (department.DepartmentId == 0)
                {
                    await db.InsertAsync(department);
                }
                else
                {
                    await db.UpdateAsync(department);
                }
                bool openAddAssignment = await DisplayAlert("Succes", "Afdeling succesvol toegevoegd. Wilt u een opdracht toevoegen?", "Ja", "Nee");
                if (openAddAssignment)
                {
                    // Open page...
                }
            });
        }
コード例 #2
0
 private void EmailTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     // Check it is a valid email
     if (InputValidationHelper.ValidInput((TextBox)sender, EmailErrorMessage, ErrorHelper.UIError.InvalidEmail))
     {
         // Check it is not in use
         InputValidationHelper.ValidInput((TextBox)sender, EmailErrorMessage, ErrorHelper.UIError.EmailInUse);
     }
     TryEnableRegisterButton();
 }
コード例 #3
0
        public IActionResult CreerNouvelEmploye(Employe Employe)
        {
            try
            {
                if (Employe == null)
                {
                    throw new ArgumentNullException(nameof(Employe));
                }

                if (Employe.Compte == null)
                {
                    throw new NullReferenceException();
                }

                if (!InputValidationHelper.IsValidUsername(Employe.NomUtilisateur))
                {
                    throw new ArgumentException(Employe.NomUtilisateur);
                }

                if (!InputValidationHelper.IsValidPassword(Employe.MotPasse))
                {
                    throw new ArgumentException(Employe.MotPasse);
                }

                Employe.Compte = _db.Compte.Where(c => c.Email == Employe.Compte.Email).FirstOrDefault();
                if (Employe.Compte.Id == 0)
                {
                    BadRequest("Error");
                }

                Employe.MotPasse = PasswordHelper.HashPassword(Employe.MotPasse);

                _db.Employe.Add(Employe);
                _db.SaveChanges();

                if (Employe.Id != 0)
                {
                    return(Ok("OK"));
                }

                return(BadRequest("Error"));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest("Requête invalide"));
            }
            catch (ArgumentException)
            {
                return(BadRequest("Informations erronées"));
            }
            catch (NullReferenceException)
            {
                return(BadRequest("Requête invalide"));
            }
        }
コード例 #4
0
        private string CheckStaffRecord()
        {
            var errorMessage = new StringBuilder();

            // First name
            if (formEmployeeFirstNameTextbox.Text.Trim().Length == 0)
            {
                errorMessage.Append("You have not entered a first name!\n");
            }

            // Last name
            if (formEmployeeLastNameTextbox.Text.Trim().Length == 0)
            {
                errorMessage.Append("You have not entered a last name!\n");
            }

            // Phone number
            if (formEmployeePhoneNumberTextbox.Text.Trim().Length == 0)
            {
                errorMessage.Append("You have not entered a phone number!\n");
            }

            // Email address
            if (formEmployeeEmailAddressTextbox.Text.Trim().Length == 0)
            {
                errorMessage.Append("You have not entered an email!\n");
            }
            else if (!InputValidationHelper.ValidInput(formEmployeeEmailAddressTextbox, ErrorHelper.UIError.InvalidEmail))
            {
                errorMessage.Append("You have not entered a valid email address!\n");
            }

            // if the email entered is in use and isn't the email already set for the selected entity
            else if (formEmployeeEmailAddressTextbox.Text != ((StaffModel)selectedRow).EmailAddress &&
                     !InputValidationHelper.ValidInput(formEmployeeEmailAddressTextbox, ErrorHelper.UIError.EmailInUse))
            {
                errorMessage.Append("The email you have entered is already in use by another user!\n");
            }

            // House Name / Number
            if (formEmployeeHouseNumberNameTextbox.Text.Trim().Length == 0)
            {
                errorMessage.Append("You have not entered a house name or number!\n");
            }

            // PostCode
            if (formEmployeePostCodeTextbox.Text.Trim().Length == 0)
            {
                errorMessage.Append("You have not entered a post code!");
            }

            return(errorMessage.ToString());
        }
コード例 #5
0
        public IActionResult ConnexionEmploye(CompteConnexion CompteConnexion)
        {
            var employe = new Employe();

            try
            {
                if (CompteConnexion == null)
                {
                    throw new ArgumentNullException(nameof(CompteConnexion));
                }


                if (!InputValidationHelper.IsValidUsername(CompteConnexion.NomDeConnexion))
                {
                    throw new ArgumentException(CompteConnexion.NomDeConnexion);
                }

                if (!InputValidationHelper.IsValidPassword(CompteConnexion.MotDePasse))
                {
                    throw new ArgumentException(CompteConnexion.MotDePasse);
                }

                employe        = _db.Employe.FirstOrDefault(e => e.NomUtilisateur == CompteConnexion.NomDeConnexion);
                employe.Compte = _db.Compte.FirstOrDefault(c => c.Id == employe.IdCompte);

                if (employe == null)
                {
                    throw new ArgumentException(CompteConnexion.NomDeConnexion);
                }



                if (!BCrypt.Net.BCrypt.Verify(CompteConnexion.MotDePasse, employe.MotPasse))
                {
                    throw new ArgumentException(CompteConnexion.MotDePasse);
                }


                return(Ok(TokenHelper.CreateToken(employe.Compte.Prenom + " " + employe.Compte.Nom, employe.Compte.Email, employe.NomUtilisateur, "employe")));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest("Requête invalide"));
            }
            catch (ArgumentException)
            {
                return(BadRequest("Informations erronées"));
            }
        }
コード例 #6
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            // check email
            string email = EmailTextBox.Text;

            // invalid email
            if (!InputValidationHelper.ValidInput(EmailTextBox, EmailErrorMessage, ErrorHelper.UIError.InvalidEmail))
            {
                return;
            }
            // otherwise valid

            // check credentials
            string password = PasswordPBox.Password;

            IUser userLoggingIn = DBAccessHelper.GetUser(email, password);

            // credentials are invalid
            if (userLoggingIn == null)
            {
                ErrorHelper.ShowInputError(ErrorHelper.UIError.EmailPasswordComboNotRecognised, EmailErrorMessage);
                ErrorHelper.ShowInputError(ErrorHelper.UIError.EmailPasswordComboNotRecognised, PasswordErrorMessage);
                return;
            }

            // customer logging in
            if (!userLoggingIn.IsStaff)
            {
                // credentials are valid
                OrderModel order = new OrderModel()
                {
                    User = userLoggingIn
                };

                ChangePageTo(new SearchProductsPage(order));
                return;
            }

            // staff logging in
            var staffMember = (StaffModel)userLoggingIn;

            ChangePageTo(new StaffLandingPage(staffMember));
        }
コード例 #7
0
        public IActionResult Connexion([FromBody] CompteConnexion compteConnexion)
        {
            Compte compte = new Compte();


            try
            {
                if (compteConnexion == null)
                {
                    throw new ArgumentNullException(nameof(compteConnexion));
                }

                if (InputValidationHelper.IsValidEmail(compteConnexion.NomDeConnexion))
                {
                    compte = _db.Compte.Where(c => c.Email == compteConnexion.NomDeConnexion).FirstOrDefault();
                }
                else
                {
                    compte = _db.Compte.Where(c => c.Email == compteConnexion.NomDeConnexion).FirstOrDefault();
                }

                if (string.IsNullOrEmpty(compte.MotPasse))
                {
                    throw new ArgumentNullException(compte.MotPasse);
                }

                if (!PasswordHelper.VerifyPassword(compteConnexion.MotDePasse, compte.MotPasse))
                {
                    throw new ArgumentException(compte.MotPasse);
                }

                return(Ok("allo"));
            }
            catch (ArgumentNullException)
            {
                return(Unauthorized("Informations erronées"));
            }
        }
コード例 #8
0
 private void PasswordConfirmPBox_PasswordChanged(object sender, RoutedEventArgs e)
 {
     InputValidationHelper.ValidInput((PasswordBox)sender, PasswordPBox, PasswordConfirmErrorMessage, ErrorHelper.UIError.PasswordMismatch);
     TryEnableRegisterButton();
 }
コード例 #9
0
 private void PhoneTextbox_TextChanged(object sender, TextChangedEventArgs e)
 {
     InputValidationHelper.ValidInput((TextBox)sender, PhoneErrorMessage, ErrorHelper.UIError.InvalidPhoneNumber);
     TryEnableRegisterButton();
 }
コード例 #10
0
 private void LastNameTextbox_TextChanged(object sender, TextChangedEventArgs e)
 {
     InputValidationHelper.ValidInput((TextBox)sender, LastNameErrorMessage, ErrorHelper.UIError.RequiredField);
     TryEnableRegisterButton();
 }
コード例 #11
0
        void saveCompany(object sender, EventArgs e)
        {
            foreach (var view in addCompanyStackLayout.Children)
            {
                if (view is Entry entry)
                {
                    if (string.IsNullOrWhiteSpace(entry.Text) && entry.Placeholder.Contains("*"))
                    {
                        DisplayAlert("Alert", "Graag alle velden met een * invullen.", "OK");
                        return;
                    }
                }
                else if (view is Picker picker)
                {
                    if (picker.SelectedItem == null)
                    {
                        DisplayAlert("Alert", "Graag een provincie invullen.", "OK");
                        return;
                    }
                }
            }
            if (addCompanyKvKNumber.Text.Count() != 8 || !int.TryParse(addCompanyKvKNumber.Text, out int result))
            {
                DisplayAlert("Alert", "Graag een correct KvK nummer invullen.", "OK");
                return;
            }

            if (!InputValidationHelper.IsZipCodeValid(addCompanyZipCode.Text))
            {
                DisplayAlert("Alert", "Graag een geldige postcode invullen.", "OK");
                return;
            }

            Task.Run(async() =>
            {
                kvk.KvKNumber = int.Parse(addCompanyKvKNumber.Text);
                if (kvk.Id == 0)
                {
                    await db.InsertAsync(kvk);
                }
                else
                {
                    await db.UpdateAsync(kvk);
                }

                company.KvKId           = kvk.Id;
                company.Province        = ((Province)addCompanyProvincePicker.SelectedItem).ProvinceName;
                company.CompanyName     = addCompanyCompanyName.Text;
                company.Address         = addCompanyAddress.Text;
                company.AddressAddition = addCompanyAddressAddition.Text;
                company.City            = addCompanyCity.Text;
                company.Zipcode         = addCompanyZipCode.Text;
                if (company.CompanyId == 0)
                {
                    await db.InsertAsync(company);
                }
                else
                {
                    await db.UpdateAsync(company);
                }
                await DisplayAlert("Succes", "Instellingen succesvol opgeslagen.", "OK");

                //navigatie back to listview... to be implemented
            });
        }
コード例 #12
0
 private void TbOffset_Validating(object sender, CancelEventArgs e)
 {
     InputValidationHelper.ValidateTextInputAsNonNegativeInt(sender as TextBox, errorProvider, Resources.TrainAdjustTimesForm_Offset_ValidationFailure);
 }
コード例 #13
0
        void SaveAssignment(object sender, EventArgs e)
        {
            foreach (var element in addAssignmentLayout.Children)
            {
                if (element is Entry entry)
                {
                    if (String.IsNullOrWhiteSpace(entry.Text) && entry.Placeholder.Contains("*"))
                    {
                        DisplayAlert("Alert", "Graag alle velden met een * invullen", "Ok");
                        return;
                    }
                }
                if (element is Picker picker)
                {
                    if (picker.SelectedItem == null)
                    {
                        DisplayAlert("Alert", "Graag een afdeling selecteren", "Ok");
                        return;
                    }
                }
            }

            if (!int.TryParse(addAssignmentCostCenterNumer.Text, out int CostCenterNumber))
            {
                DisplayAlert("Alert", "Graag een correct kostenplaatsnummer invoeren", "Ok");
                return;
            }

            // Ref: http://regexlib.com/REDetails.aspx?regexp_id=2243
            if (!Regex.IsMatch(addAssignmentHourSalary.Text, @"^([\u20AC]?[1-9]\d*\.\d{3}(?:,\d{2})?|[\u20AC]?[1-9]\d*(?:,\d{2})?|[\u20AC]?[1-9]\d*)$"))
            {
                DisplayAlert("Alert", "Graag een correct salaris invoeren", "Ok");
                return;
            }

            if (!InputValidationHelper.IsValidEmail(addAssignmentClientEmail.Text))
            {
                DisplayAlert("Alert", "Graag een correct email adres invoeren", "Ok");
                return;
            }

            if (Regex.IsMatch(addAssignmentClientMobileNumber.Text, @"[a-zA-Z]"))
            {
                DisplayAlert("Alert", "Graag een correct telefoonnnummer invoeren", "Ok");
                return;
            }

            string salary = addAssignmentHourSalary.Text.Replace(" ", "").Replace("€", "");

            if (!float.TryParse(salary, out float floatSalary))
            {
                DisplayAlert("Alert", "Graag een correct salaris invoeren", "Ok");
                return;
            }

            assignment.ClientEmailAddress = addAssignmentClientEmail.Text;
            assignment.ClientFirstName    = addAssignmentClientFirstName.Text;
            assignment.ClientLastName     = addAssignmentClientLastName.Text;
            assignment.ClientMobileNumber = addAssignmentClientMobileNumber.Text;
            assignment.DepartmentId       = selectedDepartment.DepartmentId;
            assignment.HourSalary         = floatSalary;

            Task.Run(async() =>
            {
                if (assignment.CostCenterNumber == 0)
                {
                    Assignment tempAssignment   = await db.Table <Assignment>().FirstOrDefaultAsync(x => x.CostCenterNumber == CostCenterNumber);
                    assignment.CostCenterNumber = CostCenterNumber;
                    if (tempAssignment != null)
                    {
                        bool doOverwrite = await DisplayAlert("Alert", "Er is al een opdracht met dit kostenplaatsnummer. Wilt u deze overschrijven?", "Ja", "Nee");
                        if (doOverwrite)
                        {
                            await db.InsertAsync(assignment);
                        }
                        else
                        {
                            return;
                        }
                    }
                    await db.InsertAsync(assignment);
                }
                else
                {
                    assignment.CostCenterNumber = CostCenterNumber;
                    await db.UpdateAsync(assignment);
                }

                bool openAddWorkday = await DisplayAlert("Succes", "Opdracht succesvol toegevoegd. Wilt u een werkdag toevoegen?", "Ja", "Nee");
                if (openAddWorkday)
                {
                    // do some navigating
                }
            });
        }
コード例 #14
0
        void onSaveClicked(object sender, EventArgs e)
        {
            foreach (var view in settingsStackLayout.Children)
            {
                if (view is Entry entry)
                {
                    if (entry.Placeholder.Contains("*") && string.IsNullOrWhiteSpace(entry.Text))
                    {
                        DisplayAlert("Alert", "Graag alle velden met een * invullen.", "OK");
                        return;
                    }
                }
            }

            if (kvkNumber.Text.Count() != 8 || !int.TryParse(kvkNumber.Text, out int result))
            {
                DisplayAlert("Alert", "Graag een correct KvK nummer invullen.", "OK");
                return;
            }
            if (!InputValidationHelper.IsValidEmail(email.Text))
            {
                DisplayAlert("Alert", "Graag een correct email adres nummer invullen.", "OK");
                return;
            }
            if (!InputValidationHelper.ValidateIban(bankNumber.Text))
            {
                DisplayAlert("Alert", "Graag een correct IBAN nummer invullen.", "OK");
                return;
            }
            if (!InputValidationHelper.ValidateVATNumber(vatNumber.Text))
            {
                DisplayAlert("Alert", "Graag een correct BTW nummer invullen.", "OK");
            }

            if (Regex.IsMatch(mobileNumber.Text, @"[a-zA-Z]"))
            {
                DisplayAlert("Alert", "Graag een correct telefoonnnummer invoeren", "Ok");
                return;
            }

            Task.Run(async() =>
            {
                kvk.KvKNumber = int.Parse(kvkNumber.Text);

                if (kvk.Id == 0)
                {
                    await db.InsertAsync(kvk);
                }
                else
                {
                    await db.UpdateAsync(kvk);
                }

                user.KvKId             = kvk.Id;
                user.BankaccountNumber = bankNumber.Text;
                user.EmailAddress      = email.Text;
                user.VATNumber         = vatNumber.Text;
                user.PhoneNumber       = mobileNumber.Text;
                user.UserFirstName     = firstName.Text;
                user.UserLastName      = lastName.Text;
                user.Website           = website.Text;

                if (user.UserId == 0)
                {
                    await db.InsertAsync(user);
                }
                else
                {
                    await db.UpdateAsync(user);
                }

                await DisplayAlert("Succes", "Instellingen succesvol opgeslagen.", "OK");
            });
        }
コード例 #15
0
        public IActionResult Inscription(Compte compte)
        {
            Adresse adresse;

            try
            {
                if (compte == null)
                {
                    throw new ArgumentNullException(nameof(compte));
                }


                if (!InputValidationHelper.IsValidEmail(compte.Email))
                {
                    return(BadRequest("Adresse courriel invalide"));
                }

                if (!InputValidationHelper.IsValidUsername(compte.NomUtilisateur))
                {
                    return(BadRequest("Nom d'utilisateur invalide"));
                }

                if (!InputValidationHelper.IsValidFirstName(compte.Prenom))
                {
                    return(BadRequest("Nom invalide"));
                }

                if (!InputValidationHelper.IsValidLastName(compte.Nom))
                {
                    return(BadRequest("Prénom invalide"));
                }

                if (!InputValidationHelper.IsValidBirthDate(compte.DateNaissance))
                {
                    return(BadRequest("Vous devez être âgé de 18 ans ou plus"));
                }

                if (!InputValidationHelper.IsValidPassword(compte.MotPasse))
                {
                    return(BadRequest("Le mot de passe doit contenir au moins 1 majuscule, 1 minuscule, 1 chiffre," +
                                      " 1 caractère spécial ainsi qu'être d'une longueur minimale de 5 caractères"));
                }

                if (!InputValidationHelper.IsValidAddress(compte.Adresse))
                {
                    return(BadRequest("Adresse invalide"));
                }

                compte.MotPasse = PasswordHelper.HashPassword(compte.MotPasse);

                adresse = _db.Adresse.Where(a => a.NumeroCivique == compte.Adresse.NumeroCivique &&
                                            a.Rue == compte.Adresse.Rue && a.Ville == compte.Adresse.Ville &&
                                            a.CodePostal == compte.Adresse.CodePostal).FirstOrDefault();
                if (adresse != null)
                {
                    compte.Adresse = adresse;
                }

                _db.Add(compte);
                _db.SaveChanges();


                return(Created("", ""));
            }
            catch (ArgumentNullException)
            {
                return(Unauthorized("Informations erronées"));
            }
        }