What's the correct approach for passing data from several models into a service?

Posted by Doug Chamberlain on Programmers See other posts from Programmers or by Doug Chamberlain
Published on 2011-05-24T16:30:37Z Indexed on 2011/11/21 18:08 UTC
Read the original article Hit count: 215

Filed under:
|
|

I have an AccountModel and a page where the user can upload a file. What I would like to have happen is when the user uploads the file. The PageController does something like the following. this is a quick attempt just written in the question to illustrate my question.

public class PageController : Controller {
  private Service service;
      public ActionResult Upload(HttpPostedFileBase f){
         service.savefile(f,_AccountModel_whatever.currentlyloggedinuser.taxid)          }
}


public class Service
{
// abunch of validation and error checking to make sure the file is good to store
}

Wouldn't this approach be in bad practice? Since I'm making my controller dependent on the existence of th AccountModel? This will become a HUGE program over the next few years, and I really want to maximize the quality of the framework now.

© Programmers or respective owner

Related posts about c#

Related posts about ASP.NET