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

  • SEARCH
  • Home
  • 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 3950262
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:35:28+00:00 2026-05-20T01:35:28+00:00

I’m building a site using mvc2 and have a structure like follows: Factory ->

  • 0

I’m building a site using mvc2 and have a structure like follows:

Factory -> Domain.objects -> mvc2

One factory contains an enum for logType, which details the actions which have been applied to an object.
The domain requests the object and supplies it to a MVC2 model, this is passed to a view as IEnumerable Ilog, and the view iterates over it.

My issue is that I want the view to create a link based on the log type, so I have a switch statement in the view which creates this functionality. The switch statement is utilising the enum right back in the repository, but this seems a bit wrong to me: exposing the repository to the view.

Should I encapsulate the Log type in a new IList of objects in the domain? Or is it ok referencing this enum in the repository.

If neither of these are ideal, what is the best solution?

Thanks for any help I might get.

  • 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-05-20T01:35:29+00:00Added an answer on May 20, 2026 at 1:35 am

    The best solution would be to use a view model. A view model is a class which is specially tailored to the needs of the view. So here’s a typical workflow for a controller action:

    1. Query the repository to fetch some domain objects
    2. Map those domain objects to a corresponding view model (AutoMapper could help you here)
    3. Pass the view model to the view

    So in this scenario the view has no knowledge of any of your domain models. That’s in general.

    Now for your particular case of generating different links based on the value of the enum I think that writing ifs and switches in a view makes in ugly. Don’t you find? So writing a custom HTML helper that will generate the proper link based on the view model would be great especially when your view looks like this:

    <%= Html.MyLink() %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.