1 |
|
---|
2 | using System;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using HeuristicLab.Services.Optimization.Billing.Interfaces;
|
---|
5 | namespace HeuristicLab.Services.Optimization.Billing.Model {
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Note: enum support
|
---|
9 | * Although we use EF5 enums are not supported as we target .NET 4.0.
|
---|
10 | * Therefore we use the following workaround:
|
---|
11 | * Just create an int property on your class to represent the int value of the enum.
|
---|
12 | * That's the property that EF should map, then have a "mini wrapper" property to allow you to use the enum
|
---|
13 | * For example see class PaymentInformation
|
---|
14 | * See also: http://stackoverflow.com/questions/6344032/enums-with-ef-code-first-standard-method-to-seeding-db-and-then-using
|
---|
15 | */
|
---|
16 |
|
---|
17 | public class ContactInformation : IObjectWithState {
|
---|
18 | public long ContactInformationId { get; set; }
|
---|
19 | public string OrganizationName { get; set; }
|
---|
20 | public string Street { get; set; }
|
---|
21 | public string City { get; set; }
|
---|
22 | public string State { get; set; }
|
---|
23 | public string PostalCode { get; set; }
|
---|
24 | public string LastName { get; set; }
|
---|
25 | public string FirstName { get; set; }
|
---|
26 | public string Email { get; set; }
|
---|
27 |
|
---|
28 | // Property is not mapped
|
---|
29 | // It is used to track state (disconnected entities)
|
---|
30 | public State EntityState { get; set; }
|
---|
31 | }
|
---|
32 |
|
---|
33 | public class PaymentInformation : IObjectWithState {
|
---|
34 | public long PaymentInformationId { get; set; }
|
---|
35 | public long UserId { get; set; }
|
---|
36 | public string CardNumber { get; set; }
|
---|
37 | public int PaymentMethodValue { get; set; }
|
---|
38 | public string AdditionalInformation { get; set; }
|
---|
39 |
|
---|
40 | public virtual User User { get; set; }
|
---|
41 |
|
---|
42 | public PaymentMethod PaymentMethod {
|
---|
43 | get { return (PaymentMethod)PaymentMethodValue; }
|
---|
44 | set { PaymentMethodValue = (int)value; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public State EntityState { get; set; }
|
---|
48 | }
|
---|
49 |
|
---|
50 | public enum PaymentMethod {
|
---|
51 | Cheque,
|
---|
52 | Visa,
|
---|
53 | MasterCard,
|
---|
54 | PayPal,
|
---|
55 | Diners
|
---|
56 | }
|
---|
57 |
|
---|
58 | public enum BillingType {
|
---|
59 | Pre,
|
---|
60 | Post
|
---|
61 | }
|
---|
62 |
|
---|
63 | public enum BillingPeriod {
|
---|
64 | Weekly,
|
---|
65 | Monthly,
|
---|
66 | Yearly
|
---|
67 | }
|
---|
68 |
|
---|
69 | public class Product : IObjectWithState {
|
---|
70 | public long ProductId { get; set; }
|
---|
71 | public string Name { get; set; }
|
---|
72 | public string Description { get; set; }
|
---|
73 | public string ProductType { get; set; }
|
---|
74 | public double Price { get; set; }
|
---|
75 |
|
---|
76 | public State EntityState { get; set; }
|
---|
77 | }
|
---|
78 |
|
---|
79 | public class User : IObjectWithState {
|
---|
80 | public long UserId { get; set; }
|
---|
81 | public long ContactInformationId { get; set; }
|
---|
82 | public string Name { get; set; }
|
---|
83 |
|
---|
84 | public virtual IList<PaymentInformation> PaymentInformation { get; set; }
|
---|
85 | public virtual ContactInformation ContactInformation { get; set; }
|
---|
86 |
|
---|
87 | public State EntityState { get; set; }
|
---|
88 | }
|
---|
89 |
|
---|
90 | public enum OrderState {
|
---|
91 | Created,
|
---|
92 | Active,
|
---|
93 | Suspended,
|
---|
94 | Overdue,
|
---|
95 | Finished
|
---|
96 | }
|
---|
97 |
|
---|
98 | public class Order : IObjectWithState {
|
---|
99 | public long OrderId { get; set; }
|
---|
100 | public long UserId { get; set; }
|
---|
101 | public int StateValue { get; set; }
|
---|
102 | public int BillingTypeValue { get; set; }
|
---|
103 | public int BillingPeriodValue { get; set; }
|
---|
104 | public DateTime? ActiveSince { get; set; }
|
---|
105 | public DateTime? ActiveUntil { get; set; }
|
---|
106 | public DateTime? LastBillableDay { get; set; }
|
---|
107 | public DateTime? NextBillableDay { get; set; }
|
---|
108 |
|
---|
109 | public virtual User User { get; set; }
|
---|
110 | public virtual IList<Invoice> Invoices { get; set; }
|
---|
111 | public virtual IList<OrderLine> OrderLines { get; set; }
|
---|
112 |
|
---|
113 | public OrderState State {
|
---|
114 | get { return (OrderState)StateValue; }
|
---|
115 | set { StateValue = (int)value; }
|
---|
116 | }
|
---|
117 | public BillingType BillingType {
|
---|
118 | get { return (BillingType)BillingTypeValue; }
|
---|
119 | set { BillingTypeValue = (int)value; }
|
---|
120 | }
|
---|
121 | public BillingPeriod BillingPeriod {
|
---|
122 | get { return (BillingPeriod)BillingPeriodValue; }
|
---|
123 | set { BillingPeriodValue = (int)value; }
|
---|
124 | }
|
---|
125 |
|
---|
126 | public State EntityState { get; set; }
|
---|
127 | }
|
---|
128 |
|
---|
129 | public class OrderLine : IObjectWithState {
|
---|
130 | public long OrderLineId { get; set; }
|
---|
131 | public long OrderId { get; set; }
|
---|
132 | public long ProductId { get; set; }
|
---|
133 | public int Quantity { get; set; }
|
---|
134 | public double ProductPrice { get; set; }
|
---|
135 |
|
---|
136 | public virtual Order Order { get; set; }
|
---|
137 | public virtual Product Product { get; set; }
|
---|
138 |
|
---|
139 | public State EntityState { get; set; }
|
---|
140 | }
|
---|
141 |
|
---|
142 | public enum InvoiceStatus {
|
---|
143 | Open, Overdue, Paid
|
---|
144 | }
|
---|
145 |
|
---|
146 | public class Invoice : IObjectWithState {
|
---|
147 | public long InvoiceId { get; set; }
|
---|
148 | public long UserId { get; set; }
|
---|
149 | public long OrderId { get; set; }
|
---|
150 | public DateTime InvoiceDate { get; set; }
|
---|
151 | public DateTime Due { get; set; }
|
---|
152 | public int StatusValue { get; set; }
|
---|
153 | public double Total { get; set; }
|
---|
154 | public double Tax { get; set; }
|
---|
155 | public string InvoiceDocument { get; set; }
|
---|
156 |
|
---|
157 | public virtual User User { get; set; }
|
---|
158 | public virtual Order Order { get; set; }
|
---|
159 | public virtual IList<InvoiceLine> InvoiceLines { get; set; }
|
---|
160 |
|
---|
161 | public InvoiceStatus Status {
|
---|
162 | get { return (InvoiceStatus)StatusValue; }
|
---|
163 | set { StatusValue = (int)value; }
|
---|
164 | }
|
---|
165 |
|
---|
166 | public State EntityState { get; set; }
|
---|
167 | }
|
---|
168 |
|
---|
169 | public class InvoiceLine : IObjectWithState {
|
---|
170 | public long InvoiceLineId { get; set; }
|
---|
171 | public long InvoiceId { get; set; }
|
---|
172 | public long ProductId { get; set; }
|
---|
173 | public int Quantity { get; set; }
|
---|
174 | public double ProductPrice { get; set; }
|
---|
175 |
|
---|
176 | public virtual Invoice Invoice { get; set; }
|
---|
177 | public virtual Product Product { get; set; }
|
---|
178 |
|
---|
179 | public State EntityState { get; set; }
|
---|
180 | }
|
---|
181 |
|
---|
182 | public class UsageRecord : IObjectWithState {
|
---|
183 | public long UsageRecordId { get; set; }
|
---|
184 | public long UserId { get; set; }
|
---|
185 | public long ProductId { get; set; }
|
---|
186 | public DateTime Begin { get; set; }
|
---|
187 | public DateTime End { get; set; }
|
---|
188 | public int ServiceIdentifier { get; set; }
|
---|
189 | public int ResourceIdentifier { get; set; }
|
---|
190 |
|
---|
191 | public virtual User User { get; set; }
|
---|
192 | public virtual Product Product { get; set; }
|
---|
193 |
|
---|
194 | public State EntityState { get; set; }
|
---|
195 | }
|
---|
196 | }
|
---|