示例#1
0
        public ChangeResult <string> DefineEmail(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "L'adresse email doit être définie !", m_Email, newValue));
            }
            else if (!newValue.Equals(newValue.Trim()))
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "L'addresse email ne peut pas commencer ou finir par un espace !", m_Email, newValue));
            }
            else if (!EmailHelper.IsValidEmail(newValue))
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "Le format de l'addresse email n'est pas valide !", m_Email, newValue));
            }
            else if (newValue.Length > 100)
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "L'adresse email doit faire au plus 100 caractères !", m_Email, newValue));
            }

            newValue = newValue.ToLower();
            var initialValue = m_Email;

            m_Email = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.Email, initialValue, newValue));
        }
示例#2
0
        public ChangeResult <string> DefineEmailConfirmation(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.EmailConfirmation, "L'adresse email de confirmation doit être définie !", m_EmailConfirmation, newValue));
            }
            else if (!newValue.Equals(newValue.Trim()))
            {
                return(ChangeResult <string> .Failed(this, Properties.EmailConfirmation, "L'addresse email de confirmation ne peut pas commencer ou finir par un espace !", m_EmailConfirmation, newValue));
            }
            else if (!EmailHelper.IsValidEmail(newValue))
            {
                return(ChangeResult <string> .Failed(this, Properties.EmailConfirmation, "Le format de l'addresse email de confirmation n'est pas valide !", m_EmailConfirmation, newValue));
            }
            else if (newValue.Length > 100)
            {
                return(ChangeResult <string> .Failed(this, Properties.EmailConfirmation, "L'adresse email de confirmation doit faire au plus 100 caractères !", m_EmailConfirmation, newValue));
            }
            else if (!string.IsNullOrEmpty(Email) && !newValue.Equals(Email))
            {
                return(ChangeResult <string> .Failed(this, Properties.EmailConfirmation, "L'adresse email de confirmation doit être identique à l'adresse email !", m_EmailConfirmation, newValue));
            }

            newValue = newValue.ToLower();
            var initialValue = m_EmailConfirmation;

            m_EmailConfirmation = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.EmailConfirmation, initialValue, newValue));
        }
示例#3
0
        public ChangeResult <string> DefineOldPassword(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.OldPassword, "L'ancien mot de passe est requis !", m_OldPassword, newValue));
            }
            var initialValue = m_OldPassword;

            m_OldPassword = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.OldPassword, initialValue, newValue));
        }
示例#4
0
        public ChangeResult <int> DefineBorrows(int newValue)
        {
            if (newValue < 0)
            {
                return(ChangeResult <int> .Failed(this, Properties.BorrowQuantity, "Le nombre d'emprunt ne peut pas être négatif !", m_BorrowQuantity, newValue));
            }

            var initialValue = m_BorrowQuantity;

            m_BorrowQuantity = newValue;
            return(ChangeResult <int> .Succeded(this, Properties.BorrowQuantity, initialValue, newValue));
        }
示例#5
0
        public ChangeResult <Guid> DefineToken(Guid newValue)
        {
            if (newValue == Guid.Empty)
            {
                return(ChangeResult <Guid> .Failed(this, Properties.Token, "Le token est requis !", m_Token, newValue));
            }

            var initialValue = m_Token;

            m_Token = newValue;
            return(ChangeResult <Guid> .Succeded(this, Properties.Token, initialValue, newValue));
        }
示例#6
0
        public ChangeResult <int> DefineQuantity(int newValue)
        {
            if (newValue < 0)
            {
                return(ChangeResult <int> .Failed(this, Properties.Quantity, "La quantité de copie ne peut pas être négative !", m_Quantity, newValue));
            }

            var initialValue = m_Quantity;

            m_Quantity = newValue;
            return(ChangeResult <int> .Succeded(this, Properties.Quantity, initialValue, newValue));
        }
示例#7
0
        public ChangeResult <DateTime> DefineBirthDate(DateTime newValue)
        {
            if (newValue == DateTime.MinValue)
            {
                return(ChangeResult <DateTime> .Failed(this, Properties.BirthDate, "La date de naissance doit être définie !", m_BirthDate, newValue));
            }
            else if ((DateTime.Now.Year - newValue.Year) < 13)
            {
                return(ChangeResult <DateTime> .Failed(this, Properties.BirthDate, "Il faut être agé de 13 ou plus pour s'inscrire !", m_BirthDate, newValue));
            }

            var initialValue = m_BirthDate;

            m_BirthDate = newValue;
            return(ChangeResult <DateTime> .Succeded(this, Properties.BirthDate, initialValue, newValue));
        }
示例#8
0
        public ChangeResult <AddressModel> DefineAddress(AddressModel newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <AddressModel> .Failed(this, Properties.Address, "L'adresse est requise !", m_Address, newValue));
            }
            else if (!newValue.IsValid())
            {
                return(ChangeResult <AddressModel> .Failed(this, Properties.Address, "L'adresse n'est pas valide !", m_Address, newValue));
            }

            var initialValue = m_Address;

            m_Address = newValue;
            return(ChangeResult <AddressModel> .Succeded(this, Properties.Address, initialValue, newValue));
        }
示例#9
0
        public ChangeResult <string> DefineNewPasswordConfirmation(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.NewPasswordConfirmation, "La confirmation du nouveau mot de passe est requis !", m_NewPasswordConfirmation, newValue));
            }
            else if (string.IsNullOrEmpty(NewPassword) && !newValue.Equals(NewPassword))
            {
                return(ChangeResult <string> .Failed(this, Properties.NewPasswordConfirmation, "La confirmation du nouveau mot de passe et sa confirmation sont différents !", m_NewPasswordConfirmation, newValue));
            }

            var initialValue = m_NewPasswordConfirmation;

            m_NewPasswordConfirmation = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.NewPasswordConfirmation, initialValue, newValue));
        }
示例#10
0
        public ChangeResult <string> DefineRole(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.Role, "Le role est requis !", m_Role, newValue));
            }
            newValue = newValue.Trim();
            if (!RoleData.RoleExist(newValue))
            {
                return(ChangeResult <string> .Failed(this, Properties.Role, "Le role donné n'existe pas !", m_Role, newValue));
            }

            var initialValue = m_Role;

            m_Role = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.Role, initialValue, newValue));
        }
示例#11
0
        public ChangeResult <BookModel> DefineBook(BookModel newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <BookModel> .Failed(this, Properties.Book, "Le livre est requis !", m_Book, newValue));
            }

            if (!newValue.IsValid())
            {
                return(ChangeResult <BookModel> .Failed(this, Properties.Book, "Un ou des propriétés du livres sont incorrects !", m_Book, newValue));
            }

            var initialValue = m_Book;

            m_Book = newValue;
            return(ChangeResult <BookModel> .Succeded(this, Properties.Book, initialValue, newValue));
        }
示例#12
0
        public ChangeResult <string> DefineState(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.State, "L'état de la copie du livre est requis !", m_State, newValue));
            }

            newValue = newValue.Trim();
            if (!BookHelper.StateExist(newValue))
            {
                return(ChangeResult <string> .Failed(this, Properties.State, "L'état de la copie du livre définit n'existe pas !", m_State, newValue));
            }

            var initialValue = m_State;

            m_State = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.State, initialValue, newValue));
        }
示例#13
0
        public ChangeResult <string> DefineNewPassword(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.NewPassword, "Le nouveau mot de passe est requis !", m_NewPassword, newValue));
            }
            else if (!PasswordHelper.PasswordIsValid(newValue))
            {
                return(ChangeResult <string> .Failed(this, Properties.NewPassword, "Le nouveau mot de passe doit contenir au moins une minuscule, une majuscule, un chiffre et un caractère sépcial !", m_NewPassword, newValue));
            }
            else if (string.IsNullOrEmpty(NewPasswordConfirmation) && !newValue.Equals(NewPasswordConfirmation))
            {
                return(ChangeResult <string> .Failed(this, Properties.NewPassword, "Le nouveau mot de passe et sa confirmation sont différents !", m_NewPassword, newValue));
            }

            var initialValue = m_NewPassword;

            m_NewPassword = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.NewPassword, initialValue, newValue));
        }
示例#14
0
        public ChangeResult <string> DefineEmail(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "Le nom d'utilisateur est requis !", m_Email, newValue));
            }
            else if (!EmailHelper.IsValidEmail(newValue))
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "L'addresse email n'est pas conforme !", m_Email, newValue));
            }
            else if (newValue.Length > 100)
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "L'addresse email doit faire au plus 100 caractères !", m_Email, newValue));
            }

            var initialValue = m_Email;

            m_Email = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.Email, initialValue, newValue));
        }
示例#15
0
        public ChangeResult <string> DefineAppartment(string newValue)
        {
            if (!string.IsNullOrEmpty(newValue))
            {
                newValue = newValue.Trim();
                if (newValue.Length < 1)
                {
                    return(ChangeResult <string> .Failed(this, Properties.Appartment, "L'appartment doit faire au moins 1 caractère !", m_Appartment, newValue));
                }
                else if (newValue.Length > 3)
                {
                    return(ChangeResult <string> .Failed(this, Properties.Appartment, "L'appartement doit faire au plus 3 caractères !", m_Appartment, newValue));
                }

                newValue = newValue.ToLower().FirstCharToUpper();
                var intiailValue = m_Appartment;
                m_Appartment = newValue;
                return(ChangeResult <string> .Succeded(this, Properties.Appartment, intiailValue, newValue));
            }
            return(ChangeResult <string> .Succeded(this, Properties.Appartment, m_Appartment, newValue));
        }
示例#16
0
        public ChangeResult <string> DefineZipCode(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.ZipCode, "Le code postal est requis !", m_ZipCode, newValue));
            }
            newValue = newValue.Trim();
            if (newValue.Length != 4)
            {
                return(ChangeResult <string> .Failed(this, Properties.ZipCode, "Le code postal doit faire exactement 4 caractères !", m_ZipCode, newValue));
            }
            else if (!newValue.IsDigit())
            {
                return(ChangeResult <string> .Failed(this, Properties.ZipCode, "Le code postal ne peut être composé que de chiffres !", m_ZipCode, newValue));
            }

            var initialValue = m_ZipCode;

            m_ZipCode = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.ZipCode, initialValue, newValue));
        }
示例#17
0
        public ChangeResult <string> DefineEmail(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "L'adresse email est requise !", m_Email, newValue));
            }

            if (!EmailHelper.IsValidEmail(newValue))
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "Le format de l'adresse email est incorrect !", m_Email, newValue));
            }
            else if (newValue.Length > 100)
            {
                return(ChangeResult <string> .Failed(this, Properties.Email, "L'adresse email doit faire au plus 100 caractères !", m_Email, newValue));
            }

            var initialValue = m_Email;

            m_Email = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.Email, initialValue, newValue));
        }
示例#18
0
        public ChangeResult <string> DefinePhoneNumber(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.PhoneNumber, "Le numéro de télépphone est requis !", m_PhoneNumber, newValue));
            }
            newValue = newValue.Trim();
            if (!newValue.IsDigit())
            {
                return(ChangeResult <string> .Failed(this, Properties.PhoneNumber, "Le numéro de téléphone ne doit être composé que de chiffres !", m_PhoneNumber, newValue));
            }
            else if (newValue.Length != 10)
            {
                return(ChangeResult <string> .Failed(this, Properties.PhoneNumber, "Le numéro de téléphone n'est pas valide !", m_PhoneNumber, newValue));
            }

            var initialValue = m_PhoneNumber;

            m_PhoneNumber = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.PhoneNumber, initialValue, newValue));
        }
示例#19
0
        public ChangeResult <string> DefineCity(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.City, "La ville est requise !", m_City, newValue));
            }
            newValue = newValue.Trim();
            if (newValue.Length < 3)
            {
                return(ChangeResult <string> .Failed(this, Properties.City, "La ville doit faire au moins 3 caractères !", m_City, newValue));
            }
            else if (newValue.Length > 50)
            {
                return(ChangeResult <string> .Failed(this, Properties.City, "La ville doit faire au plus 50 caractères !", m_City, newValue));
            }

            newValue = newValue.ToLower().FirstCharToUpperForAll(new char[] { ' ', '-', '\'' });
            var initialValue = m_City;

            m_City = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.City, initialValue, newValue));
        }
示例#20
0
        public ChangeResult <string> DefineStreet(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.Street, "La rue et le numéro sont requis !", m_Street, newValue));
            }
            newValue = newValue.Trim();
            if (newValue.Length < 3)
            {
                return(ChangeResult <string> .Failed(this, Properties.Street, "La rue doit faire au moins 3 caractères !", m_Street, newValue));
            }
            else if (newValue.Length > 100)
            {
                return(ChangeResult <string> .Failed(this, Properties.Street, "La rue doit faire au plus 100 caractères !", m_Street, newValue));
            }

            newValue = newValue.ToLower().FirstCharToUpperForAll(new char[] { ' ', '-', '\'' });
            var initialValue = m_Street;

            m_Street = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.Street, initialValue, newValue));
        }
示例#21
0
        public ChangeResult <string> DefineFirstName(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.FirstName, "Le prénom est requis !", m_FirstName, newValue));
            }
            newValue = newValue.Trim();
            if (newValue.Length < 2)
            {
                return(ChangeResult <string> .Failed(this, Properties.FirstName, "Le prénom doit faire au moins 2 caractères !", m_FirstName, newValue));
            }
            else if (newValue.Length > 50)
            {
                return(ChangeResult <string> .Failed(this, Properties.FirstName, "Le prénom doit faire au plus 50 caractères !", m_FirstName, newValue));
            }

            newValue = newValue.ToLower().FirstCharToUpperForAll(new char[] { ' ', '-' });
            var initialValue = m_FirstName;

            m_FirstName = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.FirstName, initialValue, newValue));
        }
示例#22
0
        public ChangeResult <string> DefineLastName(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.LastName, "Le nom de famille est requis !", m_LastName, newValue));
            }

            newValue = newValue.Trim();
            if (newValue.Length < 2)
            {
                return(ChangeResult <string> .Failed(this, Properties.LastName, "Le nom de famille doit faire au moins 2 caractères !", m_LastName, newValue));
            }
            else if (newValue.Length > 50)
            {
                return(ChangeResult <string> .Failed(this, Properties.LastName, "Le nom de famille doit faire au plus 50 caractères !", m_LastName, newValue));
            }

            var initialValue = m_LastName;

            m_LastName = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.LastName, initialValue, newValue));
        }
示例#23
0
        public ChangeResult <string> DefineGender(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.Gender, "Le genre est requis !", m_Gender, newValue));
            }
            newValue = newValue.Trim();
            if (newValue.Length != 5)
            {
                return(ChangeResult <string> .Failed(this, Properties.Gender, "Le genre doit faire exactement 5 caractères !", m_Gender, newValue));
            }
            else if (!GendersData.GetGenders().Any(x => x.Equals(newValue)))
            {
                return(ChangeResult <string> .Failed(this, Properties.Gender, "Le genre rentré n'existe pas !", m_Gender, newValue));
            }

            newValue = newValue.ToLower().FirstCharToUpper();
            var initialValue = m_Gender;

            m_Gender = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.Gender, initialValue, newValue));
        }
示例#24
0
        public ChangeResult <string> DefineFullCity(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.FullCity, "La ville et le code postal sont requis !", m_FullCity, FullCity));
            }

            newValue = newValue.Trim();
            if (newValue.Length < 7)
            {
                return(ChangeResult <string> .Failed(this, Properties.FullCity, "La ville et le code postal doivent faire au moins 7 caractères ensembles !", m_FullCity, newValue));
            }
            else if (newValue.Length > 54)
            {
                return(ChangeResult <string> .Failed(this, Properties.FullCity, "La ville et le code postal doivent faire au plus 54 caractères ensembles !", m_FullCity, newValue));
            }

            var initialValue = m_FullCity;

            m_FullCity = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.FullCity, initialValue, newValue));
        }
示例#25
0
        public ChangeResult <string> DefineFullAddress(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.FullAddress, "L'adresse complète est requise !", m_FullAddress, newValue));
            }

            newValue = newValue.Trim();
            if (newValue.Length < 4)
            {
                return(ChangeResult <string> .Failed(this, Properties.FullAddress, "L'adresse complète doit faire au moins 4 caractères !", m_FullAddress, newValue));
            }
            else if (newValue.Length > 103)
            {
                return(ChangeResult <string> .Failed(this, Properties.FullAddress, "L'addresse complète doit faire au plus 103 caractères !", m_FullAddress, newValue));
            }

            var initialValue = m_FullAddress;

            m_FullAddress = newValue;
            return(ChangeResult <string> .Succeded(this, Properties.FullAddress, initialValue, newValue));
        }
示例#26
0
        public ChangeResult <string> DefineName(string newValue)
        {
            if (newValue is null)
            {
                return(ChangeResult <string> .Failed(this, Properties.Name, "Le nom de la catégorie est requis !", m_Name, newValue));
            }
            else
            {
                newValue = newValue.Trim();
                if (newValue.Length < 5)
                {
                    return(ChangeResult <string> .Failed(this, Properties.Name, "Le nom de la catégorie doit faire au moins 5 caractères !", m_Name, newValue));
                }
                else if (newValue.Length > 30)
                {
                    return(ChangeResult <string> .Failed(this, Properties.Name, "Le nom de la catégorie doit faire au plus 30 caractères !", m_Name, newValue));
                }

                newValue = newValue.ToLower().FirstCharToUpperForAll(new char[] { ' ', '/', '-' });
                var initialValue = m_Name;
                m_Name = newValue;
                return(ChangeResult <string> .Succeded(this, Properties.Name, initialValue, newValue));
            }
        }