Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs @ 12940

Last change on this file since 12940 was 10013, checked in by spimming, 11 years ago

#1888:

  • enabled transactions
  • enabled tracing output
  • set correct invoice data
  • saving invoices
File size: 6.0 KB
Line 
1
2using System;
3using System.Collections.Generic;
4using HeuristicLab.Services.Optimization.Billing.Interfaces;
5namespace 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 SubTotal { get; set; }
154    public double Total { get; set; }
155    public double Tax { get; set; }
156    public string InvoiceDocument { get; set; }
157
158    public virtual User User { get; set; }
159    public virtual Order Order { get; set; }
160    public virtual IList<InvoiceLine> InvoiceLines { get; set; }
161
162    public InvoiceStatus Status {
163      get { return (InvoiceStatus)StatusValue; }
164      set { StatusValue = (int)value; }
165    }
166
167    public State EntityState { get; set; }
168  }
169
170  public class InvoiceLine : IObjectWithState {
171    public long InvoiceLineId { get; set; }
172    public long InvoiceId { get; set; }
173    public long ProductId { get; set; }
174    public int Quantity { get; set; }
175    public double ProductPrice { get; set; }
176
177    public virtual Invoice Invoice { get; set; }
178    public virtual Product Product { get; set; }
179
180    public State EntityState { get; set; }
181  }
182
183  public class UsageRecord : IObjectWithState {
184    public long UsageRecordId { get; set; }
185    public long UserId { get; set; }
186    public long ProductId { get; set; }
187    public DateTime Begin { get; set; }
188    public DateTime End { get; set; }
189    public int ServiceIdentifier { get; set; }
190    public int ResourceIdentifier { get; set; }
191
192    public virtual User User { get; set; }
193    public virtual Product Product { get; set; }
194
195    public State EntityState { get; set; }
196  }
197}
Note: See TracBrowser for help on using the repository browser.