Beispiel #1
0
        /// <summary>
        /// Returns a list of all CustomRedirect objects in the Dynamic Data Store.
        /// </summary>
        /// <returns></returns>
        public List <CustomRedirect> GetCustomRedirects(bool excludeIgnored, int siteId)
        {
            DynamicDataStore             store = DataStoreFactory.GetStore(typeof(CustomRedirect));
            IEnumerable <CustomRedirect> customRedirects;

            if (excludeIgnored)
            {
                customRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl)
                                  where s.State.Equals((int)State.Saved) & s.SiteId == siteId
                                  select s;
            }
            else
            {
                customRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl)
                                  where s.SiteId == siteId
                                  select s;
            }
            if (customRedirects.Any())
            {
                return(customRedirects.ToList());
            }
            return(new List <CustomRedirect>());
        }
Beispiel #2
0
        /// <summary>
        /// Delete CustomObject object from Data Store that has given "OldUrl" property
        /// </summary>
        /// <param name="oldUrl"></param>
        /// <param name="siteId"></param>
        public void DeleteCustomRedirect(string oldUrl, int siteId)
        {
            // Get hold of the datastore
            DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect));

            //find object with matching property "OldUrl"
            var urlEncode = HttpUtility.UrlEncode(oldUrl);

            if (urlEncode != null)
            {
                var savedUrl = urlEncode.ToLower().Replace("%2f", "/");
                var filters  = new Dictionary <string, object>
                {
                    { OldUrlPropertyName, savedUrl.ToLower() },
                    { SiteIdPropertyName, siteId }
                };
                CustomRedirect match = store.Find <CustomRedirect>(filters).SingleOrDefault();
                if (match != null)
                {
                    store.Delete(match);
                }
            }
        }