Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7994295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:05:42+00:00 2026-06-04T14:05:42+00:00

I am using mvc to create a feed api for different integrations. For example,

  • 0

I am using mvc to create a feed api for different integrations. For example, say I want to provide feed of questions posted on my site to others. The initial implementation was to pass the name of the third party as a parameter to an action method on the feeds controller.

public XmlResult Get(string partner)
{

    //Call the business layer and get the List<Questions>       


    if (!string.IsNullOrEmpty(partner))
    {
        partner = partner.ToLower();

        switch (partner)
        {
            case "org1":
                Org1XMLFeedViewModel org1FeedViewModel = new Org1XMLFeedViewModel();
                org1FeedViewModel.LastBuildDate = DateTime.Now;

                foreach (QuestionInfo Question in QuestionsForFeed)
                {
                    Org1XMLFeedQuestionViewModel QuestionForFeed = new Org1XMLFeedQuestionViewModel(Question);
                    Org1FeedViewModel.Questions.Add(QuestionForFeed);
                }
                return new XmlResult(Org1FeedViewModel);                        
        case "org2":
        //similar to org1, use org2 ViewModel                       
            default:
                return new XmlResult(QuestionsForFeed);
        }
    }

    return new XmlResult(QuestionsForFeed);
}

However, now there is a thought that perhaps different view models should not be within the same action method. Thus instead of passing the partner as a parameter have different action methods for different partners.

Which one is better and why? Or is there a better pattern that comes to your mind?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:05:43+00:00Added an answer on June 4, 2026 at 2:05 pm

    Holy smokes that controller needs to go on a diet 😉

    OT: Personally, I would recommend that you split them into different action methods, kind of separating it out so that each Action can only return one type of controller because it’s that type of Action.

    Doing it this way also means that you can abstract away that logic out of the Controller, as the best practice for MVC is thin Controller, fat Model, you wouldn’t be able to adhere to that that here because it’s your controller that has to determine the model type in this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.Net MVC to create a web site which needs to do some
I am trying to create a web site app using MVC 3- The problem
I am new to Subsonic3. Want to create a project using MVC and subsonic
Can we create a WEB GRID dynamically using JAVASCRIPT ? I am using MVC
I am trying to create a custom authentication scheme in ASP.NET MVC using form
I am using ASP.Net MVC along with Jquery to create a page which contains
I needed to create an application using Struts2 as MVC,Hibernate for data access and
I need to create a web application using ASP.NET MVC, jQuery and web standards
I am trying to create a drop down list using asp.net mvc. Model: public
what is the preferred practice when linq2sql using (in asp.net mvc applications): to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.