Adding form fields and receiving them in controller
It's a weird situation. I have a table in the database which stores details of files uploaded on the server. I have a controller and view in place for managing data in this table.
I also have a controller/view to upload files to the server.
I want to combine these two into a single view. But I don't know how.
.
Re: Adding form fields and receiving them in controller
Dude, you should have nothing related to the database in your controllers.
Controllers should just pass on data to and from your view to and from your repository implementations.
Saying that:
Create a viewmodel which will contain the data you want to send to the database, as well as a collection of files you want to upload.
When the model get posted to the controller, pass off the fields that must go to the database to a repository function doing that, and the files to another function doing that.
Something in that line. But the way you asked make it sound like you want to look a bit more at MVC best practices.
Don't over complicate things like they do in WebForms. Controllers should be thin. They just orchestrate things.
Re: Adding form fields and receiving them in controller
I understand the general principles, however there are often constraints in what we can and cannot do. I had to drum up the interface to a small database in a very short time, and MVC at least automated most of the mundane tasks for me, coupled with ADO.Net Entities. All I need is a way of extending just one form to accomodate the file upload.
I am well aware my MVC may not be the best, but right now, it's the best that I can do.
.