예제 #1
0
        static void Main()
        {
            Console.WriteLine("Enter PESEL");
            PeselValidator peselValidator = new PeselValidator();
            string         pesel          = Console.ReadLine();

            Console.WriteLine(peselValidator.ValidatePesel(pesel));
        }
예제 #2
0
        public ActionResult VerifyAge(Pesel pesel)
        {
            if (pesel.PeselNumber == null || pesel.BirthDate == null)
            {
                return(View());
            }
            else
            {
                var             currentUserId    = UserId(User.Identity.Name);
                List <Users>    userList         = new List <Users>();
                IPeselValidator peselValidator   = new PeselValidator();
                bool            checkPesel       = peselValidator.ValidatePesel(pesel.PeselNumber);
                bool            checkPeselAndAge = false;
                if (checkPesel == false)
                {
                    ViewBag.peselError = "Podany pesel jest niepoprawny";
                    return(View());
                }

                if (peselValidator.ValidateAge(pesel.BirthDate))
                {
                    checkPeselAndAge = peselValidator.ValidatePeselAndBirthDate(pesel.PeselNumber, pesel.BirthDate);
                }

                if (checkPeselAndAge)
                {
                    using (ProjektEntities context = new ProjektEntities())
                    {
                        var user = context.Users.Where(a => a.id == currentUserId).FirstOrDefault();
                        user.email           = user.email;
                        user.username        = user.username;
                        user.ConfirmPassword = user.password;
                        user.role_id         = 3;
                        context.SaveChanges();
                    }



                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ViewBag.peselError = "Podany pesel i data nie zgadzają się ze sobą";
                    return(View());
                }
            }
        }
예제 #3
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            var firstName = FirstNameBox.Text;
            var lastName  = LastNameBox.Text;
            var pesel     = PeselBox.Text;
            var email     = EmailBox.Text;
            var doB       = DoB.Text;
            var street    = StreetBox.Text;
            var city      = CityBox.Text;
            var country   = CountryBox.Text;
            var zipCode   = ZipCodeBox.Text;
            var phone     = PhoneBox.Text;


            var nameValidator  = new NameValidator();
            var mailValidator  = new MailValidator();
            var peselValidator = new PeselValidator();
            var dobValidator   = new DateOfBirthValidator();
            var phoneValidator = new PhoneValidator();

            if (!nameValidator.ValidateName(firstName))
            {
                MessageBox.Show("Podałeś nieprawidłowę imię.");
            }
            else if (!nameValidator.ValidateName(lastName))
            {
                MessageBox.Show("Podałeś nieprawidłowe nazwisko");
            }
            else if (!peselValidator.ValidatePesel(pesel))
            {
                MessageBox.Show("Podałeś nieprawidłowy numer PESEL");
            }
            else if (!mailValidator.ValidateMail(email))
            {
                MessageBox.Show("Podałeś nieprawidłowy adres Email");
            }
            else if (!phoneValidator.ValidatePhoneNumber(phone))
            {
                MessageBox.Show("Nieprawidłowy numer telefonu");
            }

            else if (!dobValidator.ValidateDoB(doB))
            {
                MessageBox.Show("Nieprawidłowa data urodzenia");
            }
            else if (string.IsNullOrEmpty(street) || string.IsNullOrEmpty(zipCode) || string.IsNullOrEmpty(country) ||
                     string.IsNullOrEmpty(city))
            {
                MessageBox.Show("Pole adresowe nie może być puste");
            }


            else
            {
                var gender          = (Gender)Enum.Parse(typeof(Gender), GenderComboBox.Text);
                var account         = new BankAccount();
                var personalAccount = new PersonalAccount(firstName, lastName, doB, gender, pesel, email, street,
                                                          zipCode,
                                                          country, phone, city, account)
                {
                    BankAccount = { Balance = 0.0 }
                };

                var filePath  = Environment.CurrentDirectory + @"\" + "Personal_Accounts.xml";
                var listToXml = new ListToXml();
                listToXml.PersonalAccounts(personalAccount, filePath);

                Close();
            }
        }