/// <summary> /// Creates test feeds /// </summary> /// <param name="TEST_ID"></param> /// <param name="OUTPUT_FORMAT"></param> /// <returns></returns> public IActionResult CreateFeedSubmit(Nullable <int> TEST_ID, Nullable <int> OUTPUT_FORMAT) { IActionResult rslt = new BadRequestResult(); // if id has test value, proceed if (TEST_ID.HasValue) { // get the int int nTestID = Convert.ToInt32(TEST_ID); // get the output value int nOutputFormat = 0; if (OUTPUT_FORMAT.HasValue) { nOutputFormat = Convert.ToInt32(OUTPUT_FORMAT); } // save the session; session.SessionVariables.LastCreateTestID = nTestID; session.SessionVariables.LastCreateOutputFormat = nOutputFormat; session.Save(); // create a new feed Rss20 rss = new Rss20(); // switch the test switch (TEST_ID) { case TEST_CREATE_CHANNEL_USING_OBJECTS: CreateChannelUsingObjects(rss); break; case TEST_CREATE_CHANNEL_USING_HELPER_METHODS: CreateChannelUsingHelperMethods(rss); break; case TEST_CREATE_ONE_CORE_ITEM: CreateChannelWithOneCoreItem(rss); break; case TEST_CREATE_ONE_CORE_ITEM_USING_HELPER_METHODS: CreateChannelWithOneCoreItemHelperMethods(rss); break; case TEST_CREATE_CHANNEL_WITH_EXT_PROPS_USING_OBJECTS: CreateChannelWithExtendedPropertiesUsingObjects(rss); break; case TEST_CREATE_CHANNEL_WITH_EXT_PROPS_USING_HELPER_METHODS: CreateChannelWithExtendedPropertiesUsingHelperMethods(rss); break; case TEST_CREATE_CHANNEL_WITH_EXT_PROPS_MEDIA_USING_OBJECTS: CreateChannelWithExtendedPropertiesAndMediaUsingObjects(rss); break; case TEST_CREATE_CHANNEL_WITH_EXT_PROPS_MEDIA_USING_HELPER_METHODS: CreateChannelWithExtendedPropertiesAndMediaUsingHelperMethods(rss); break; case TEST_CREATE_CHANNEL_WITH_EXT_PLUS_ONE_EXT_ITEM_USING_OBJECTS: CreateChannelWithExtendedPropertiesAndOneItemWithExtendedPropertiesNoMediaUsingObjects(rss); break; case TEST_CREATE_CHANNEL_WITH_EXT_PLUS_ONE_EXT_ITEM_WITH_MEDIA_USING_OBJECTS: CreateChannelWithExtendedPropertiesAndOneItemWithExtendedPropertiesAndMediaUsingObjeccts(rss); break; case TEST_CREATE_ONE_ITEM_WITH_MEDIA_CONTENT: CreateOneItemWithMediaContent(rss); break; case TEST_CREATE_ONE_ITEM_WITH_MEDIA_CONTENT_AND_MEDIA_OPTIONS: CreateOneItemWithMediaContentAndMediaOptions(rss); break; case TEST_CREATE_ONE_ITEM_WITH_MEDIA_GROUP: CreateOneItemWithMediaGroup(rss); break; case TEST_CREATE_ONE_ITEM_WITH_MEDIA_GROUP_WITH_MEDIA_OPTIONS: CreateOneItemWithMediaGroupAndMediaOptions(rss); break; } // do the dump switch (nOutputFormat) { case 0: rslt = Content(rss.GetXml(), "application/xml"); break; case 1: string json = JsonConvert.SerializeObject(rss, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); rslt = Content(json, "application/json"); break; } // switch } // end if not string null or empty return(rslt); }
/// <summary> /// ReadFeedSubmit handles the submission /// </summary> /// <param name="COMBOBOX_FEED_URL"></param> /// <param name="OUTPUT_FORMAT"></param> /// <returns></returns> public async Task <IActionResult> ReadFeedSubmit(string COMBOBOX_FEED_URL, Nullable <int> OUTPUT_FORMAT) { IActionResult rslt = new BadRequestResult(); int nOutputFormat = 0; if (OUTPUT_FORMAT.HasValue) { nOutputFormat = Convert.ToInt32(OUTPUT_FORMAT); } if (!string.IsNullOrEmpty(COMBOBOX_FEED_URL)) { string url = COMBOBOX_FEED_URL.Trim(); if (url.Length > 0) { // create a new feed Rss20 rss = new Rss20(); rss.PersistResponseXml = true; rss.SortItemsOnLoad = true; HttpStatusCode r = await rss.LoadUrl(url); // set the session variables session.SessionVariables.LastReadUrl = url; session.SessionVariables.LastReadOutputFormat = nOutputFormat; session.Save(); if (rss.ResponseStatusCode == HttpStatusCode.OK) { switch (nOutputFormat) { case 0: rslt = View("~/Views/Home/ReadFeedDisplay.cshtml", rss); break; case 1: rslt = Content(rss.GetXml(), "application/xml"); break; case 2: rslt = Content(rss.ResponseXml, "application/xml"); break; case 3: rslt = Content(rss.ResponseRawXml, "application/xml"); break; case 4: string json = JsonConvert.SerializeObject(rss, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); rslt = Content(json, "application/json"); break; } // switch } } } return(rslt); }