[9602] | 1 |
|
---|
| 2 | using System;
|
---|
[9550] | 3 | using System.Collections.Generic;
|
---|
[9645] | 4 | using HeuristicLab.Services.Optimization.Billing.Interfaces;
|
---|
[9602] | 5 | namespace HeuristicLab.Services.Optimization.Billing.Model {
|
---|
[9550] | 6 |
|
---|
[9602] | 7 | /*
|
---|
| 8 | * Note: enum support
|
---|
| 9 | * Although we use EF5 enums are not supported as we target .NET 4.0.
|
---|
[9641] | 10 | * Therefore we use the following workaround:
|
---|
[9602] | 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 |
|
---|
[9645] | 17 | public class ContactInformation : IObjectWithState {
|
---|
[9576] | 18 | public long ContactInformationId { get; set; }
|
---|
[9550] | 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; }
|
---|
[9645] | 27 |
|
---|
| 28 | // Property is not mapped
|
---|
| 29 | // It is used to track state (disconnected entities)
|
---|
| 30 | public State EntityState { get; set; }
|
---|
[9550] | 31 | }
|
---|
| 32 |
|
---|
[9645] | 33 | public class PaymentInformation : IObjectWithState {
|
---|
[9582] | 34 | public long PaymentInformationId { get; set; }
|
---|
[9602] | 35 | public long UserId { get; set; }
|
---|
[9582] | 36 | public string CardNumber { get; set; }
|
---|
[9602] | 37 | public int PaymentMethodValue { get; set; }
|
---|
[9582] | 38 | public string AdditionalInformation { get; set; }
|
---|
[9602] | 39 |
|
---|
| 40 | public virtual User User { get; set; }
|
---|
| 41 |
|
---|
| 42 | public PaymentMethod PaymentMethod {
|
---|
| 43 | get { return (PaymentMethod)PaymentMethodValue; }
|
---|
| 44 | set { PaymentMethodValue = (int)value; }
|
---|
| 45 | }
|
---|
[9645] | 46 |
|
---|
| 47 | public State EntityState { get; set; }
|
---|
[9582] | 48 | }
|
---|
| 49 |
|
---|
[9550] | 50 | public enum PaymentMethod {
|
---|
| 51 | Cheque,
|
---|
| 52 | Visa,
|
---|
| 53 | MasterCard,
|
---|
| 54 | PayPal,
|
---|
| 55 | Diners
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[9582] | 58 | public enum BillingType {
|
---|
| 59 | Pre,
|
---|
| 60 | Post
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | public enum BillingPeriod {
|
---|
| 64 | Weekly,
|
---|
| 65 | Monthly,
|
---|
| 66 | Yearly
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[9645] | 69 | public class Product : IObjectWithState {
|
---|
[9576] | 70 | public long ProductId { get; set; }
|
---|
[9550] | 71 | public string Name { get; set; }
|
---|
| 72 | public string Description { get; set; }
|
---|
| 73 | public string ProductType { get; set; }
|
---|
| 74 | public double Price { get; set; }
|
---|
[9645] | 75 |
|
---|
| 76 | public State EntityState { get; set; }
|
---|
[9550] | 77 | }
|
---|
| 78 |
|
---|
[9645] | 79 | public class User : IObjectWithState {
|
---|
[9576] | 80 | public long UserId { get; set; }
|
---|
[9641] | 81 | public long ContactInformationId { get; set; }
|
---|
[9556] | 82 | public string Name { get; set; }
|
---|
[9602] | 83 |
|
---|
[9582] | 84 | public virtual IList<PaymentInformation> PaymentInformation { get; set; }
|
---|
[9641] | 85 | public virtual ContactInformation ContactInformation { get; set; }
|
---|
[9645] | 86 |
|
---|
| 87 | public State EntityState { get; set; }
|
---|
[9550] | 88 | }
|
---|
| 89 |
|
---|
| 90 | public enum OrderState {
|
---|
| 91 | Created,
|
---|
| 92 | Active,
|
---|
| 93 | Suspended,
|
---|
| 94 | Overdue,
|
---|
| 95 | Finished
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[9645] | 98 | public class Order : IObjectWithState {
|
---|
[9576] | 99 | public long OrderId { get; set; }
|
---|
| 100 | public long UserId { get; set; }
|
---|
[9602] | 101 | public int StateValue { get; set; }
|
---|
| 102 | public int BillingTypeValue { get; set; }
|
---|
| 103 | public int BillingPeriodValue { get; set; }
|
---|
[9582] | 104 | public DateTime? ActiveSince { get; set; }
|
---|
| 105 | public DateTime? ActiveUntil { get; set; }
|
---|
[9619] | 106 | public DateTime? LastBillableDay { get; set; }
|
---|
| 107 | public DateTime? NextBillableDay { get; set; }
|
---|
[9576] | 108 |
|
---|
| 109 | public virtual User User { get; set; }
|
---|
| 110 | public virtual IList<Invoice> Invoices { get; set; }
|
---|
| 111 | public virtual IList<OrderLine> OrderLines { get; set; }
|
---|
[9602] | 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 | }
|
---|
[9645] | 125 |
|
---|
| 126 | public State EntityState { get; set; }
|
---|
[9550] | 127 | }
|
---|
| 128 |
|
---|
[9645] | 129 | public class OrderLine : IObjectWithState {
|
---|
[9576] | 130 | public long OrderLineId { get; set; }
|
---|
| 131 | public long OrderId { get; set; }
|
---|
| 132 | public long ProductId { get; set; }
|
---|
[9550] | 133 | public int Quantity { get; set; }
|
---|
| 134 | public double ProductPrice { get; set; }
|
---|
[9576] | 135 |
|
---|
| 136 | public virtual Order Order { get; set; }
|
---|
| 137 | public virtual Product Product { get; set; }
|
---|
[9645] | 138 |
|
---|
| 139 | public State EntityState { get; set; }
|
---|
[9550] | 140 | }
|
---|
| 141 |
|
---|
[9586] | 142 | public enum InvoiceStatus {
|
---|
| 143 | Open, Overdue, Paid
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[9645] | 146 | public class Invoice : IObjectWithState {
|
---|
[9576] | 147 | public long InvoiceId { get; set; }
|
---|
| 148 | public long UserId { get; set; }
|
---|
| 149 | public long OrderId { get; set; }
|
---|
[9619] | 150 | public DateTime InvoiceDate { get; set; }
|
---|
[9550] | 151 | public DateTime Due { get; set; }
|
---|
[9602] | 152 | public int StatusValue { get; set; }
|
---|
[9619] | 153 | public double Total { get; set; }
|
---|
| 154 | public double Tax { get; set; }
|
---|
[9550] | 155 | public string InvoiceDocument { get; set; }
|
---|
[9576] | 156 |
|
---|
| 157 | public virtual User User { get; set; }
|
---|
| 158 | public virtual Order Order { get; set; }
|
---|
[9579] | 159 | public virtual IList<InvoiceLine> InvoiceLines { get; set; }
|
---|
[9602] | 160 |
|
---|
| 161 | public InvoiceStatus Status {
|
---|
| 162 | get { return (InvoiceStatus)StatusValue; }
|
---|
| 163 | set { StatusValue = (int)value; }
|
---|
| 164 | }
|
---|
[9645] | 165 |
|
---|
| 166 | public State EntityState { get; set; }
|
---|
[9550] | 167 | }
|
---|
| 168 |
|
---|
[9645] | 169 | public class InvoiceLine : IObjectWithState {
|
---|
[9576] | 170 | public long InvoiceLineId { get; set; }
|
---|
| 171 | public long InvoiceId { get; set; }
|
---|
| 172 | public long ProductId { get; set; }
|
---|
[9550] | 173 | public int Quantity { get; set; }
|
---|
| 174 | public double ProductPrice { get; set; }
|
---|
[9576] | 175 |
|
---|
| 176 | public virtual Invoice Invoice { get; set; }
|
---|
| 177 | public virtual Product Product { get; set; }
|
---|
[9645] | 178 |
|
---|
| 179 | public State EntityState { get; set; }
|
---|
[9550] | 180 | }
|
---|
| 181 |
|
---|
[9645] | 182 | public class UsageRecord : IObjectWithState {
|
---|
[9576] | 183 | public long UsageRecordId { get; set; }
|
---|
| 184 | public long UserId { get; set; }
|
---|
[9579] | 185 | public long ProductId { get; set; }
|
---|
[9558] | 186 | public DateTime Begin { get; set; }
|
---|
| 187 | public DateTime End { get; set; }
|
---|
[9579] | 188 | public int ServiceIdentifier { get; set; }
|
---|
| 189 | public int ResourceIdentifier { get; set; }
|
---|
[9576] | 190 |
|
---|
[9579] | 191 | public virtual User User { get; set; }
|
---|
| 192 | public virtual Product Product { get; set; }
|
---|
[9645] | 193 |
|
---|
| 194 | public State EntityState { get; set; }
|
---|
[9558] | 195 | }
|
---|
[9550] | 196 | }
|
---|