Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

best place to use a web service in MVC4

Posted on 2013-10-23
3
Medium Priority
?
248 Views
Last Modified: 2013-10-30
Hi, I have inherited a MVC4 application that was using a database to retrieve customer data, but now that information is available as a web service.

My confusion is should I access this web service in the ViewModel or should I go all the way to the Model?

pls note I'm new to MVC in ASP.net, not to mention MVC4.

thanks!
0
Comment
Question by:Mydeen Yussouf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39596288
A viewmodel is used to only represent the data of your view (hence the name). It would not make sense to call this data from such classes. Since the web service is effectively your data store, I would say that the model would be the place to retrieve your data.
0
 
LVL 1

Author Comment

by:Mydeen Yussouf
ID: 39599476
But what if the information gathered from the web service is only relevant to the view? Say a picture that is used in the view but never stored back in the model or in the underlying database? thanks!
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39600384
What if the service definition changes, or what if it comes from a different source? If the structure of the view is driven by what the user needs to see, regardless of the source, then you wouldn't want to couple your view to the underlying model (of the service). If you did, then any time the service definition changes you would have to change the view as well. If the structure of the view is driven by displaying whatever the service returns, then perhaps it would be OK to just display the model associated with the service, because if the service definition ever changed, you would have to update the view to accommodate the new or missing fields anyway.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question