Esempio n. 1
0
        protected void BindDescriptors()
        {
            CheckBoxList DescriptorsObj = (CheckBoxList)formView.FindControl("Descriptors");
            IEnumerable <KeyValuePair <int, string> > DescriptorsForScope = LookupBLL.GetDescriptorsForScope(ViewData.Scope);

            if (ViewData.IsUserStateScope)
            {
                bool RemoveShipDirectorDescriptor = true;
                if (ViewData.IsAdmin)
                {
                    //If a Ship Director does not exist for the State, the Ship Director Descriptor can be shown
                    if (!LookupBLL.GetShipDirectorForState(ViewData.StateFIPS).HasValue)
                    {
                        RemoveShipDirectorDescriptor = false;
                    }
                }

                //Ship Director already exists for the State. Need not show it for State Level Admins
                if (RemoveShipDirectorDescriptor)
                {
                    DescriptorsObj.DataSource = (from scope in DescriptorsForScope where scope.Key != Descriptor.ShipDirector.EnumValue <int>() select scope);
                }
            }
            else
            {
                DescriptorsObj.DataSource = DescriptorsForScope;
            }

            DescriptorsObj.DataTextField  = "Value";
            DescriptorsObj.DataValueField = "Key";
            DescriptorsObj.DataBind();

            foreach (ListItem item in DescriptorsObj.Items)
            {
                if (item.Attributes["CustomValue"] == null)
                {
                    item.Attributes.Add("CustomValue", item.Value);
                }
                else
                {
                    item.Attributes["CustomValue"] = item.Value;
                }

                if (item.Attributes["onClick"] == null)
                {
                    item.Attributes.Add("onClick", string.Format("HandleDescriptorlist('{0}', {1})", DescriptorsObj.ClientID, item.Value));
                }
                else
                {
                    item.Attributes["onClick"] = string.Format("HandleDescriptorlist('{0}', {1})", DescriptorsObj.ClientID, item.Value);
                }
            }
        }
Esempio n. 2
0
        protected void RegisterUserCommand(object sender, EventArgs e)
        {
            //if(valid)
            Page.Validate("RegisterForm");

            bool FormIsValid = IsFormValid();

            //For some reason, CaptchaText EnableViewState=false isn't working. So doing this...
            CaptchaText.Text = string.Empty;

            if (!FormIsValid)
            {
                DisplayMessage("Please fix the error(s) displayed in red and submit again", true);
                return;
            }

            //sammit-start
            if (PasswordValidation.DoesTextContainsWord(Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains a dictionary word and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesTextContainsFirstLastName(Password.Text.Trim().ToLower(), FirstName.Text.Trim().ToLower(), LastName.Text.Trim().ToLower(), MiddleName.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains either FirstName/MiddleName/LastName and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesPassWordContainsEmail(Email.Text.Trim().ToLower(), Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains your email-id and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesContainFourConsecutive(Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains 4 consecutive letter/number and is not allowed.", true);
                return;
            }
            //sammit-end

            string UserName = Email.Text.Trim();

            if (RegisterUserBLL.DoesUserNameExist(UserName))
            {
                DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                return;
            }
            else
            {
                //If Role selected is SHIP Admin, Check if a Ship Director already exists for the Chosen state
                if (_selectedRole.IsStateAdmin && chBoxIsShipDirector.Checked)
                {
                    if (LookupBLL.GetShipDirectorForState(ddlStates.SelectedValue.Trim()).HasValue)
                    {
                        DisplayMessage(string.Format("A SHIP Director already exists for state of {0}", State.GetStateName(StateFIPSSelected)), true);
                        return;
                    }
                }

                //Fill personal profile info here...
                RegistrationObject regObj = new RegistrationObject();
                regObj.FirstName      = FirstName.Text.Trim();
                regObj.MiddleName     = MiddleName.Text.Trim();
                regObj.LastName       = LastName.Text.Trim();
                regObj.NickName       = NickName.Text.Trim();
                regObj.Suffix         = Suffix.Text.Trim();
                regObj.Honorifics     = Honorifics.Text.Trim();
                regObj.SecondaryEmail = SecondaryEmail.Text.Trim();
                regObj.PrimaryPhone   = PrimaryPhone.Text.Trim();
                regObj.SecondaryPhone = SecondaryPhone.Text.Trim();

                //Fill login info and Role
                regObj.PrimaryEmail  = UserName;
                regObj.ClearPassword = Password.Text.Trim(); //sammit
                regObj.Password      = Password.Text.Trim();
                regObj.RoleRequested = _selectedRole;

                regObj.OldShipUserId         = OldShipUserId;
                regObj.IsRegistrationRequest = true;

                //GetStateFIPS (including CMS User)
                regObj.StateFIPS = GetStateFIPSForNewUser();

                //Get regional IDs (AgencyID, Sub State Regional ID etc)
                switch (regObj.RoleRequested.scope)
                {
                case Scope.CMSRegional:
                    regObj.UserRegionalAccessProfile.RegionId = int.Parse(ddlCMSRegion.SelectedValue.Trim());
                    break;

                case Scope.SubStateRegion:
                    regObj.UserRegionalAccessProfile.RegionId = int.Parse(ddlSubStateRegion.SelectedValue.Trim());
                    break;

                case Scope.Agency:
                    regObj.UserRegionalAccessProfile.RegionId = int.Parse(ddlAgency.SelectedValue.Trim());
                    break;

                case Scope.State:
                    regObj.IsShipDirector = chBoxIsShipDirector.Checked;
                    break;
                }

                //Populate User Descriptors for the Regions other than Agencies
                PopulateUserDescriptors(ref regObj);


                //Register
                IRegisterUser regBLL = RegisterUserBLL.CreateRegistrationProviderObject(regObj);
                regBLL.ValidateData();
                if (regBLL.IsValid)
                {
                    if (!regBLL.Save())
                    {
                        DisplayMessage("Unable to complete registration. " + regBLL.ErrorMessage, true);
                    }
                    else
                    {
                        ShowSuccess();
                        ClearForm();
                    }
                }
                else
                {
                    DisplayMessage("Error. Validation error occured during registration. " + regBLL.ErrorMessage, true);
                }
            }
        }