/// <summary>
        /// Metadata page.
        /// </summary>
        /// <param name="uuid"></param>
        /// <param name="organization"></param>
        /// <param name="title"></param>
        /// <param name="orderby"></param>
        /// <returns>/metadata/{organization}/{title}/{uuid}</returns>
        public ActionResult Index(string uuid, string organization = null, string title = null, string orderby = "title")
        {
            MetadataViewModel model = null;

            //try
            //{
            model = _metadataService.GetMetadataViewModelByUuid(uuid);
            model = Sort(model, orderby);
            //}
            //catch (InvalidOperationException exception)
            //{
            //    Log.Error("Metadata with uuid: " + uuid + " not found in Geonetwork.", exception);
            //    //throw new Exception("Metadata with uuid: " + uuid + " not found in Geonetwork.");
            //}
            if (model == null)
            {
                Log.Error("Metadata with uuid: " + uuid + " not found.");
                return(new HttpNotFoundResult("Metadata with uuid: " + uuid + " not found in Geonetwork."));
            }

            SeoUrl url = model.CreateSeoUrl();

            if (!url.Matches(organization, title) && !string.IsNullOrWhiteSpace(organization))
            {
                return(RedirectToActionPermanent("Index", new { organization = url.Organization, title = url.Title, uuid = uuid }));
            }

            return(View(model));
        }
Пример #2
0
        public void ShouldReturnFalseWhenOrganizationDoesNotMatch()
        {
            var seoUrl = new SeoUrl("Skog og landskap", "AR-5");

            seoUrl.Matches("skogoglandskap", "ar-5").Should().BeFalse();
        }
Пример #3
0
        public void ShouldReturnFalseWhenTitleDoesNotMatch()
        {
            var seoUrl = new SeoUrl("Skog og landskap", "AR-5");

            seoUrl.Matches("skog-og-landskap", "ar5sadfsdf").Should().BeFalse();
        }
Пример #4
0
        public void ShouldReturnTrueWhenBothOrganizationAndTitleMatches()
        {
            var seoUrl = new SeoUrl("Skog og landskap", "WMS AR-5");

            seoUrl.Matches("skog-og-landskap", "wms-ar-5").Should().BeTrue();
        }