secret
Last active

  • Download Gist
Document Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
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;
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.