Example #1
0
        public static bool ValidateUser(PortalUserContract user, out string msg)
        {
            try
            {
                if (user == null)
                {
                    msg = "User object is null or empty";
                    return(false);
                }
                if (string.IsNullOrEmpty(user.UserName) || user.UserName.Length < 8)
                {
                    msg = "User name is null or empty / less than 8 character length";
                    return(false);
                }
                if (!RegExValidator.IsEmailValid(user.Email))
                {
                    msg = "Invalid email address";
                    return(false);
                }
                if (string.IsNullOrEmpty(user.FirstName))
                {
                    msg = "Invalid first name";
                    return(false);
                }
                if (string.IsNullOrEmpty(user.LastName))
                {
                    msg = "Invalid last name";
                    return(false);
                }

                msg = "";
                return(true);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(false);
            }
        }