NET MVC

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    NET MVC

    Hello,

    I am using ASP.NET MVC and I am running into a problem.

    I have a List Of MyClass which is a property of my controller
    ViewData.

    In the View I have a form where I need to display the List in the CSV
    format.
    When I submit the form I need to convert that CSV data to a list
    before I save it to the database using Linq.

    The View also displays the same data in an ordered list. And there are
    other view which do the same.

    How should I implement this and where to make the conversions? In the
    View? In the Controller?

    Thanks,
    Miguel
  • Peter Duniho

    #2
    Re: NET MVC

    On Mon, 07 Jul 2008 06:59:21 -0700, shapper <mdmoura@gmail. comwrote:
    [...]
    In the View I have a form where I need to display the List in the CSV
    format.
    When I submit the form I need to convert that CSV data to a list
    before I save it to the database using Linq.
    >
    [...]
    How should I implement this and where to make the conversions? In the
    View? In the Controller?
    IMHO, there's no "right answer" to the question. Personally, I would
    generally make the view responsible for all data conversions, inasmuch as
    they are just different ways of looking at the model. But to some extent,
    MVC is just something to use as your design guide. If in your situation
    it works better or seems more appropriate for the controller part of your
    code to handle data conversion of that nature, by all means do it that way.

    A design pattern should be something that aids you. If it constrains you,
    it should only do so in a beneficial way. If you find a design pattern
    constraining you in a way that seems only detrimental, and you feel that
    you can prove to yourself that it _is_ only detrimental, then ignore that
    constraint.

    If nothing else, you may find later that you were wrong, and you'll learn
    something about why the constraint is important. And it could turn out
    that you were right, in which case you'll have avoided a lot of headaches
    trying to comply with an arbitrary, useless constraint. :)

    Pete

    Comment

    Working...