コード例 #1
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            //the client side validation (browser) done by the validation controls can be re-executed on the server
            if (Page.IsValid)
            {
                //after validating your raw data again, if you have logical validation or business rules to check, they can now be done.
                //Business Rule: Terms must be checked.
                if (Terms.Checked)
                {
                    //accept entry
                    // create an instance of the Entry
                    Entry theEntry = new Entry();
                    theEntry.FirstName      = FirstName.Text;
                    theEntry.LastName       = LastName.Text;
                    theEntry.StreetAddress1 = StreetAddress1.Text;
                    theEntry.StreetAddress2 = StreetAddress2.Text;
                    theEntry.City           = City.Text;
                    theEntry.Province       = Province.SelectedValue;
                    theEntry.PostalCode     = PostalCode.Text;
                    theEntry.EmailAddress   = EmailAddress.Text;

                    //add the instance to the data collection
                    contestEntries.Add(theEntry);

                    //display the List<Entry> in the GridView
                    EntriesList.DataSource = contestEntries;
                    EntriesList.DataBind();
                }
                else
                {
                    //reject entry
                    Message.Text = "You did not agree to the contest terms. Entry Rejected.";
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Binds the results.
        /// </summary>
        private void BindResults(bool list)
        {
            SearchSort sortObject = CatalogEntrySearchCriteria.DefaultSortOrder;
            //string sort = SortBy.SelectedValue;
            //if (!String.IsNullOrEmpty(sort))
            //{
            //    if (sort.Equals("name", StringComparison.OrdinalIgnoreCase))
            //        sortObject = new SearchSort("displayname");
            //    else if (sort.Equals("plh", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower());
            //    else if (sort.Equals("phl", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower(), true);
            //}

            var group = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            SearchFilterHelper         helper   = SearchFilterHelper.Current;
            CatalogEntrySearchCriteria criteria = helper.CreateSearchCriteria("", sortObject);

            //AddNodesToCriteria(criteria);
            criteria.RecordsToRetrieve = 25;
            criteria.StartingRecord    = _startRowIndex;
            criteria.ClassTypes.Add("Product");

            var searchManager = new SearchManager(AppContext.Current.ApplicationName);

            try
            {
                var results = searchManager.Search(criteria);
                if (results == null)
                {
                    return;
                }

                var resultIndexes = results.GetKeyFieldValues <int>();
                var entries       = CatalogContext.Current.GetCatalogEntries(resultIndexes, group);
                if (entries.Entry != null)
                {
                    var ds = CreateDataSource(entries, results.TotalCount);
                    if (!list)
                    {
                        EntriesList.DataSource = ds;
                        EntriesList.DataBind();
                        EntriesList.Visible = true;
                        listView.Visible    = false;
                    }
                    else
                    {
                        listView.DataSource = ds;
                        listView.DataBind();
                        EntriesList.Visible = false;
                        listView.Visible    = true;
                    }

                    if (results.TotalCount < 25)
                    {
                        DataPager3.Visible = false;
                    }
                }

                _filters = helper.SelectedFilters;
                _facets  = results.FacetGroups;

                if (_filters != null && _filters.Length > 0)
                {
                    ActiveFilterList.DataSource = _filters;
                    ActiveFilterList.DataBind();
                    ActiveFilterList.Visible = true;
                }
                else
                {
                    ActiveFilterList.Visible = false;
                }

                if (_facets != null && _facets.Length > 0)
                {
                    FilterList.Visible    = true;
                    FilterList.DataSource = _facets;
                    FilterList.DataBind();
                }
                else
                {
                    FilterList.Visible = false;
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger(GetType()).Error(ex.Message, ex);
            }
        }