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 7541201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:50:01+00:00 2026-05-30T07:50:01+00:00

So, I’ve been building a brand new website to replace our current classic asp

  • 0

So, I’ve been building a brand new website to replace our current classic asp site. I set up a base project and added in all the different technologies I would be using.

Ninject
Automapper
PagedList
EF 4.0

So far I have a working prototype of the website. It pulls data from the database, and displays in on my page. I think I am not following a pattern correctly. Because my controller action looks strange. I’m beginning to think I need to change my injection to inject my service into my viewmodel? Is it common to insert a service into a ViewModel?

ViewModel

 public class ParcelDetailViewModel
    {
        public Property Property { get; set; }
        public int CurrentYear { get; set; }
        public IEnumerable<AltOwnership> AltOwnership { get; set; }
        public Ownership Ownership { get; set; }
        public TotalValues TotalValues { get; set; }
        public SiteAddressViewModel SiteAddress { get; set; }
        public Value CurrentValues { get; set; }

        public Transfer LatestTransfer { get; set; }
        public LegalDescription LegalDescription { get; set; }

    }

Controller

public class PropertyController : Controller
{
    ICamaService _service = null;

    [Inject]
    public PropertyController(ICamaService  service)
    {
        _service = service;
    }

    //TODO: ADD ACTIONS

    public ViewResult List(int? page, int? size = 100)
    {
        var result = _service.GetProperties(page,size);
        IList<ParcelDetailViewModel> ViewModel;
        ViewModel = new List<ParcelDetailViewModel>();
        Mapper.Map<IEnumerable<Models.Property>, IEnumerable<ParcelDetailViewModel>>(result, ViewModel);
        return View(ViewModel.ToPagedList(page ?? 1, size ?? 100));

    }


    public ViewResult Details(string id)
    {
        var property = _service.GetProperty(id);
        var acct = property.AccountNumber;
        var AltOwners = _service.GetAltOwners(id);
        var LegalDescription = _service.GetLegalDescription(id);
        var Legals = _service.GetLegals(id).FirstOrDefault();
        var Ownership = _service.GetOwnership((decimal)property.OwnerLookup);
        var Values = _service.GetValues(acct);
        var TotalValues = _service.GetTotalValues(acct);
        var Location = _service.GetLocation(property.LocationLookup);

        ParcelDetailViewModel ViewModel = new ParcelDetailViewModel();
        SiteAddressViewModel SitusAddress = new SiteAddressViewModel();

        ViewModel.SiteAddress = SitusAddress;

        Mapper.Map<Models.Property, ParcelDetailViewModel>(property, ViewModel);
        Mapper.Map<IEnumerable<AltOwnership>, ParcelDetailViewModel>(AltOwners, ViewModel);
        Mapper.Map<Ownership, ParcelDetailViewModel>(Ownership, ViewModel);
        Mapper.Map<TotalValues, ParcelDetailViewModel>(TotalValues, ViewModel);

        Mapper.Map(Location, SitusAddress);
        Mapper.Map(property, SitusAddress);


        return View(ViewModel);
    }
  • 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-30T07:50:02+00:00Added an answer on May 30, 2026 at 7:50 am

    Injecting services into controllers is perfectly correct.

    On the other hand, injecting any services into view models would be against the idea of view models – classes which hold data and no actions. What would you do with a service inside a view model?

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.