get and set for class in model - MVC 2 asp.net
- by bergin
Hi there,
I want to improve the program so it has a proper constructor but also works with the models environment of MVC.
I currently have:
public void recordDocument(int order_id, string filename, string physical_path, string slug, int bytes)
{
ArchiveDocument doc = new ArchiveDocument();
doc.order_id = order_id;
doc.filename = filename;
doc.physical_path = physical_path;
doc.slug = slug;
doc.bytes = bytes;
db.ArchiveDocuments.InsertOnSubmit(doc);
}
This obviously should be a constructor and should change to the leaner:
public void recordDocument(ArchiveDocument doc)
{
db.ArchiveDocuments.InsertOnSubmit(doc);
}
with a get & set somewhere else - not sure of the syntax - do I create a partial class?
so: creating in the somewhere repository -
ArchiveDocument doc =
new ArchiveDocument(order_id, idTaggedFilename, physical_path, slug, bytes);
and then:
namespace ordering.Models
{
public partial class ArchiveDocument
{
int order_id, string filename, string physical_path, string slug, int bytes;
public archiveDocument(int order_id, string filename, string physical_path, string slug, int bytes){
this.order_id = order_id;
etc
}
}
How should I alter the code?