Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
public class Document
{
private string docID;
private string docType;
private DateTime docCreated;
private DateTime docUpdated;
private string docCreatedBy;
private string docUpdatedBy;
private DocumentData d;
public Document()
{
d = new DocumentData();
}
[BsonId]
public ObjectId Id { get; set; }
public string DocID
{
get
{
return this.docID;
}
set
{
try
{
this.docID = value;
if (this.docID == "")
{
throw new Exception("DocumentID empty.");
}
}
catch (Exception e)
{
throw new Exception(e.Message.ToString());
}
}
}
public string DocType
{
get
{
return this.docType;
}
set
{
try
{
this.docType = value;
if (this.docType == "")
{
throw new Exception("DocumentType empty.");
}
switch (value)
{
case "Invoice":
break;
default:
throw new Exception("Document type invalit or not found.");
break;
}
}
catch (Exception e)
{
throw new Exception(e.Message.ToString());
}
}
}
//[BsonDateTimeOptions(DateOnly = true)]
public DateTime DocCreated
{
get
{
return this.docCreated;
}
set
{
this.docCreated = value;
}
}
//[BsonDateTimeOptions(DateOnly = true)]
public DateTime DocUpdated
{
get
{
return this.docUpdated;
}
set
{
this.docUpdated = DateTime.Now;
}
}
public string DocumentUpdatedBy
{
get
{
return this.docUpdatedBy;
}
set
{
this.docUpdatedBy = value;
}
}
public string DocCreatedBy { get; set; }
public IList<DFile> Files { get; set; }
public void Save()
{
//Insert New Document Here.
d.Save(this);
}
public void Add()
{
d.Add(this);
}
public void Update()
{
//Update Document Here.
}
public void FindByDocID(String DocID)
{
d.FindByDocID(DocID);
}
public void MergeFiles(Document doc)
{
//this.Files = this.Files.Concat(doc.Files).;
foreach(DFile file in doc.Files)
{
this.Files.Add(file);
}
}
}
public class DFile
{
private string fileName;
private ObjectId fileLocation;
private DateTime fileCreatedDate;
private DateTime fileUploadedDate;
private ObjectId id;
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
public ObjectId Id
{
get
{
return this.id;
}
set
{
ObjectId id = new ObjectId();
this.id = id;
}
}
public string FileName
{
get
{
return this.fileName;
}
set
{
this.fileName = value;
}
}
public ObjectId FileLocation
{
get
{
return this.fileLocation;
}
set
{
if (this.fileLocation == null)
{
throw new Exception("File Location is empty.");
}
else
{
this.fileLocation = value;
}
}
}
//[BsonDateTimeOptions(DateOnly = true)]
public DateTime FileCreatedDate
{
get
{
return this.fileCreatedDate;
}
set
{
this.fileCreatedDate = value;
}
}
//[BsonDateTimeOptions(DateOnly = true)]
public DateTime FileUploadedDate
{
get
{
return this.fileUploadedDate;
}
set
{
this.fileUploadedDate = DateTime.Now;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.