get and set for class in model - MVC 2 asp.net

Posted by bergin on Stack Overflow See other posts from Stack Overflow or by bergin
Published on 2010-06-09T11:18:13Z Indexed on 2010/06/09 11:22 UTC
Read the original article Hit count: 215

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about mvc