Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 15694 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
RevLine 
[9602]1
2using System;
[9550]3using System.Collections.Generic;
[9645]4using HeuristicLab.Services.Optimization.Billing.Interfaces;
[9602]5namespace 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; }
[10013]153    public double SubTotal { get; set; }
[9619]154    public double Total { get; set; }
155    public double Tax { get; set; }
[9550]156    public string InvoiceDocument { get; set; }
[9576]157
158    public virtual User User { get; set; }
159    public virtual Order Order { get; set; }
[9579]160    public virtual IList<InvoiceLine> InvoiceLines { get; set; }
[9602]161
162    public InvoiceStatus Status {
163      get { return (InvoiceStatus)StatusValue; }
164      set { StatusValue = (int)value; }
165    }
[9645]166
167    public State EntityState { get; set; }
[9550]168  }
169
[9645]170  public class InvoiceLine : IObjectWithState {
[9576]171    public long InvoiceLineId { get; set; }
172    public long InvoiceId { get; set; }
173    public long ProductId { get; set; }
[9550]174    public int Quantity { get; set; }
175    public double ProductPrice { get; set; }
[9576]176
177    public virtual Invoice Invoice { get; set; }
178    public virtual Product Product { get; set; }
[9645]179
180    public State EntityState { get; set; }
[9550]181  }
182
[9645]183  public class UsageRecord : IObjectWithState {
[9576]184    public long UsageRecordId { get; set; }
185    public long UserId { get; set; }
[9579]186    public long ProductId { get; set; }
[9558]187    public DateTime Begin { get; set; }
188    public DateTime End { get; set; }
[9579]189    public int ServiceIdentifier { get; set; }
190    public int ResourceIdentifier { get; set; }
[9576]191
[9579]192    public virtual User User { get; set; }
193    public virtual Product Product { get; set; }
[9645]194
195    public State EntityState { get; set; }
[9558]196  }
[9550]197}
Note: See TracBrowser for help on using the repository browser.