示例#1
0
    internal bool NeedsToBeQpEncoded()
    {
        if (LastName.Any(x => x.NeedsToBeQpEncoded()))
        {
            return(true);
        }

        if (FirstName.Any(x => x.NeedsToBeQpEncoded()))
        {
            return(true);
        }

        if (MiddleName.Any(x => x.NeedsToBeQpEncoded()))
        {
            return(true);
        }

        if (Prefix.Any(x => x.NeedsToBeQpEncoded()))
        {
            return(true);
        }

        if (Suffix.Any(x => x.NeedsToBeQpEncoded()))
        {
            return(true);
        }

        return(false);
    }
示例#2
0
文件: Contact.cs 项目: alexthayn/HW09
 private void ValidateLastName()
 {
     if (LastName == null || LastName.Any(Char.IsWhiteSpace))
     {
         errors[nameof(LastName)] = "Last name must be valid with no extra whitespace.";
     }
     else
     {
         errors[nameof(LastName)] = null;
     }
     OnPropertyChanged(nameof(LastName));
 }
示例#3
0
 private bool ValidateLastName()
 {
     if (LastName == null || LastName.Equals(String.Empty) || LastName.Any(Char.IsWhiteSpace))
     {
         errors[nameof(LastName)] = "Last name must contain no spaces, and cannot be empty.";
         return(false);
     }
     else
     {
         errors[nameof(LastName)] = null;
         return(true);
     }
 }
示例#4
0
        public virtual string this[string columnName]
        {
            get
            {
                string       error_message = String.Empty;
                PropertyInfo property      = this.GetType().GetProperty(columnName);
                if (property != null && property.IsDefined(typeof(RequiredAttribute), true))
                {
                    RequiredAttribute required_attribute = new RequiredAttribute();
                    if (!required_attribute.IsValid(property.GetValue(this)))
                    {
                        return("Заполните обязательное поле!");
                    }
                }
                switch (columnName)
                {
                case "FirstName":
                    if (FirstName != null && FirstName.Any(c => Char.IsDigit(c)))
                    {
                        error_message = "Введите имя русскими или латинскими буквами!";
                    }
                    break;

                case "LastName":
                    if (LastName != null && LastName.Any(c => Char.IsDigit(c)))
                    {
                        error_message = "Введите фамилию русскими или латинскими буквами!";
                    }
                    break;

                case "Patronym":
                    if (Patronym != null && Patronym.Any(c => Char.IsDigit(c)))
                    {
                        error_message = "Введите отчество русскими или латинскими буквами!";
                    }
                    break;
                }
                return(error_message);
            }
        }
示例#5
0
        async Task Register()
        {
            if (CityModel == null)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Odaberi grad!", "Ok");

                return;
            }
            if (CarModel == null)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Odaberi model automobila!", "Ok");

                return;
            }

            if (Password != PasswordConfirmation)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Lozinke se ne podudaraju!", "Unesite ponovo");

                return;
            }
            var listUsers = await _usersService.Get <List <Data.Model.Users> >(null);

            if (Username != null)
            {
                foreach (var item in listUsers)
                {
                    if (Username == item.Username)
                    {
                        await Application.Current.MainPage.DisplayAlert("Greška", "Korisničko ime već postoji.", "Pokušajte ponovo");

                        return;
                    }
                }
            }
            //Name
            if (string.IsNullOrWhiteSpace(FirstName) || FirstName.Length < 3)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Ime je obavezno polje!Minimalna dužina mora biti 3 karaktera", "Ok");

                return;
            }

            if (char.IsLower(FirstName[0]))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Prvo slovo imena mora biti veliko!", "Ok");

                return;
            }
            bool containsInt = FirstName.Any(char.IsDigit);

            if (containsInt)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Brojevi u imenu nisu dozovljeni!", "Ok");

                return;
            }

            //Last name
            if (string.IsNullOrWhiteSpace(LastName) || LastName.Length < 3)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Prezime je obavezno polje!Minimalna dužina mora biti 3 karaktera", "Ok");

                return;
            }

            if (char.IsLower(LastName[0]))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Prvo slovo prezimena mora biti veliko!", "Ok");

                return;
            }
            bool containsInta = LastName.Any(char.IsDigit);

            if (containsInta)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Brojevi u prezimenu nisu dozovljeni!", "Ok");

                return;
            }
            //Email

            if (string.IsNullOrWhiteSpace(Email))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Email je obavezno polje!", "Ok");

                return;
            }

            if (!Regex.IsMatch(Email, @"([a-z]+)([\\.]?)([a-z]*)([@])(yahoo|outlook|gmail|hotmail|fit|edu.fit)(.ba|.com|.org)"))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Email mora biti u formatu: nešto@(gmail,hotmail,fit,edu.fit,outlook,yahoo).(ba,com,org)", "Ok");

                return;
            }

            //PhoneNumber
            if (string.IsNullOrWhiteSpace(PhoneNumber))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Broj telefona je obavezno polje!", "Ok");

                return;
            }

            if (!Regex.IsMatch(PhoneNumber, @"(06[0-9])([/])([0-9]){3}([-])([0-9]){3}$"))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Broj telefona mora biti u formatu: 06X/XXX-XXX", "Ok");

                return;
            }

            //Username
            if (string.IsNullOrWhiteSpace(Username) || Username.Length < 3)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Korisničko ime je obavezno polje!Minimalna dužina mora biti 3 karaktera", "Ok");

                return;
            }

            if (string.IsNullOrWhiteSpace(Password))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Unesi lozinku!", "Ok");

                return;
            }
            if (string.IsNullOrWhiteSpace(PasswordConfirmation))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Unesi potvrdu lozinke!", "Ok");

                return;
            }



            var request = new UserInsertUpdateRequest()
            {
                FirstName            = FirstName,
                LastName             = LastName,
                DateOfBirth          = DateOfBirth,
                Email                = Email,
                PhoneNumber          = PhoneNumber,
                Username             = Username,
                Password             = Password,
                PasswordConfirmation = PasswordConfirmation,
                CityID               = CityModel.CityID,
                CarBrandID           = CarModel.CarBrandID,
                CarModelID           = CarModel.CarModelID,
                RoleID               = 2
            };


            var modelUser = _usersService.Insert <Data.Model.Users>(request);



            if (modelUser != null)
            {
                await Application.Current.MainPage.DisplayAlert("Uspješno ste napravili profil.", "Sada se prijavite.", "Ok");

                await Application.Current.MainPage.Navigation.PushModalAsync(new LoginPage());
            }
        }
示例#6
0
        public async Task SaveChanges()
        {
            if (NewPassword != NewPasswordConfirmation)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Nove Lozinke se ne podudaraju!", "Unesite ponovo");

                return;
            }
            var listUsers = await _usersService.Get <List <Data.Model.Users> >(null);

            if (Username != null)
            {
                foreach (var item in listUsers)
                {
                    if (Username == item.Username && item.UserID != APIService.UserID)
                    {
                        await Application.Current.MainPage.DisplayAlert("Greška", "Korisničko ime već postoji.", "Pokušajte ponovo");

                        return;
                    }
                }
            }
            //Name
            if (string.IsNullOrWhiteSpace(FirstName) || FirstName.Length < 3)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Ime je obavezno polje!Minimalna dužina mora biti 3 karaktera", "Ok");

                return;
            }

            if (char.IsLower(FirstName[0]))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Prvo slovo imena mora biti veliko!", "Ok");

                return;
            }
            bool containsInt = FirstName.Any(char.IsDigit);

            if (containsInt)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Brojevi u imenu nisu dozovljeni!", "Ok");

                return;
            }

            //Last name
            if (string.IsNullOrWhiteSpace(LastName) || LastName.Length < 3)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Prezime je obavezno polje!Minimalna dužina mora biti 3 karaktera", "Ok");

                return;
            }

            if (char.IsLower(LastName[0]))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Prvo slovo prezimena mora biti veliko!", "Ok");

                return;
            }
            bool containsInta = LastName.Any(char.IsDigit);

            if (containsInta)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Brojevi u prezimenu nisu dozovljeni!", "Ok");

                return;
            }
            //Email

            if (string.IsNullOrWhiteSpace(Email))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Email je obavezno polje!", "Ok");

                return;
            }

            if (!Regex.IsMatch(Email, @"([a-z]+)([\\.]?)([a-z]*)([@])(yahoo|outlook|gmail|hotmail|fit|edu.fit)(.ba|.com|.org)"))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Email mora biti u formatu: nešto@(gmail,hotmail,fit,edu.fit,outlook,yahoo).(ba,com,org)", "Ok");

                return;
            }

            //PhoneNumber
            if (string.IsNullOrWhiteSpace(PhoneNumber))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Broj telefona je obavezno polje!", "Ok");

                return;
            }

            if (!Regex.IsMatch(PhoneNumber, @"(06[0-9])([/])([0-9]){3}([-])([0-9]){3}$"))
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Broj telefona mora biti u formatu: 06X/XXX-XXX", "Ok");

                return;
            }

            //Username
            if (string.IsNullOrWhiteSpace(Username) || Username.Length < 3)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Korisničko ime je obavezno polje!Minimalna dužina mora biti 3 karaktera", "Ok");

                return;
            }


            var request = new UserInsertUpdateRequest()
            {
                FirstName   = FirstName,
                LastName    = LastName,
                DateOfBirth = DateOfBirth,
                Email       = Email,
                PhoneNumber = PhoneNumber,
                Username    = Username,
                //CityID = CityModel.CityID,
                //CarBrandID = CarModel.CarBrandID,
                //CarModelID = CarModel.CarModelID,
                RoleID = 2
            };

            if (CityModel != null)
            {
                request.CityID = CityModel.CityID;
            }

            if (CarModel != null)
            {
                request.CarModelID = CarModel.CarModelID;
                request.CarBrandID = CarModel.CarBrandID;
            }

            if (!string.IsNullOrEmpty(NewPassword))
            {
                request.Password             = NewPassword;
                request.PasswordConfirmation = NewPasswordConfirmation;
            }


            var modelUserUpdated = await _usersService.Update <Data.Model.Users>(APIService.UserID, request);


            if (modelUserUpdated != null)
            {
                await Application.Current.MainPage.DisplayAlert("Uspješno", "Izmijene uspješno napravljenje. Prijavite se ponovo da bi se podaci osvježili.", "OK");

                await Application.Current.MainPage.Navigation.PushModalAsync(new LoginPage());
            }
        }