private int CheckSubdomain()
        {
            int subdomainStationId = 0;

            if (UrlSubdomain != String.Empty)
            {
                DollarSaverDB.StationDataTable stationLookup = stationAdapter.GetBySubdomain(UrlSubdomain);

                if (stationLookup.Count == 1)
                {
                    subdomainStationId = stationLookup[0].StationId;
                }
                else
                {
                    invalidSubdomain = true;
                }
            }

            return(subdomainStationId);
        }
예제 #2
0
        void saveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Station.IsActive = isActiveBox.Checked;

                String code = codeBox.Text.Trim().ToUpper();

                if (code == String.Empty)
                {
                    ErrorMessage = "Code is required";
                    return;
                }

                if (code.Length < 3 || code.Length > 20)
                {
                    ErrorMessage = "Code must be between 3 and 20 characters";
                    return;
                }

                DollarSaverDB.StationDataTable stationCodeLookup = stationAdapter.GetByCode(code);

                if (stationCodeLookup.Count == 1 && stationCodeLookup[0].StationId != Station.StationId)
                {
                    InfoMessage = "Code is already in use";
                    return;
                }

                Station.Code = code;

                String subdomain = subdomainBox.Text.Trim().ToLower();

                if (subdomain != String.Empty)
                {
                    if (!Regex.IsMatch(subdomain, @"\w+([-]\w+)*"))
                    {
                        ErrorMessage = "Subdomain can only contain letters, numbers and dashes";
                        return;
                    }


                    DollarSaverDB.StationDataTable stationLookup = stationAdapter.GetBySubdomain(subdomain);

                    if (stationLookup.Count == 1 && stationLookup[0].StationId != Station.StationId)
                    {
                        InfoMessage = "Subdomain is already in use";
                        return;
                    }

                    Station.Subdomain = subdomain;
                }
                else
                {
                    Station.SetSubdomainNull();
                }

                stationAdapter.Update(Station);
                InfoMessage = "Station Updated";


                RedirectToSuperAdminHome();
            }
        }