Beispiel #1
0
        } //this function is to Encode Password and send to DB Table

        public bool AddNewUser(UserInfoEntity uie)
        {
            if (string.IsNullOrEmpty(uie.Name) || string.IsNullOrWhiteSpace(uie.Name))
            {
                throw new Exception("Name cannot be blank or empty");
            }
            if (string.IsNullOrWhiteSpace(uie.Address) || string.IsNullOrWhiteSpace(uie.Address))
            {
                throw new Exception("Address cannot be blank or empty");
            }
            if (uie.MobNo <= 0)
            {
                throw new Exception("Mobile Number cannot be zero or negative");
            }
            if (uie.MobNo.ToString().Length < 10)
            {
                throw new Exception("Mobile Number has to be 10 digits");
            }
            if (string.IsNullOrWhiteSpace(uie.EmailID) || string.IsNullOrWhiteSpace(uie.EmailID))
            {
                throw new Exception("EmailID cannot be blank or empty");
            }
            if (string.IsNullOrWhiteSpace(uie.Password) || string.IsNullOrWhiteSpace(uie.Password))
            {
                throw new Exception("Password cannot be blank or empty");
            }
            if (uie.Password.Length >= 4 && uie.Password.Length <= 10)
            {
                uie.Password = EncodePasswordToBase64(uie.Password);
            }
            else
            {
                throw new Exception("Password length has to be between 5 to 10 characters");
            }
            return(dal.AddNewUser(uie));
        }