using System; using System.Collections.Generic; using HeuristicLab.Services.Optimization.Billing.Interfaces; namespace HeuristicLab.Services.Optimization.Billing.Model { /* * Note: enum support * Although we use EF5 enums are not supported as we target .NET 4.0. * Therefore we use the following workaround: * Just create an int property on your class to represent the int value of the enum. * That's the property that EF should map, then have a "mini wrapper" property to allow you to use the enum * For example see class PaymentInformation * See also: http://stackoverflow.com/questions/6344032/enums-with-ef-code-first-standard-method-to-seeding-db-and-then-using */ public class ContactInformation : IObjectWithState { public long ContactInformationId { get; set; } public string OrganizationName { get; set; } public string Street { get; set; } public string City { get; set; } public string State { get; set; } public string PostalCode { get; set; } public string LastName { get; set; } public string FirstName { get; set; } public string Email { get; set; } // Property is not mapped // It is used to track state (disconnected entities) public State EntityState { get; set; } } public class PaymentInformation : IObjectWithState { public long PaymentInformationId { get; set; } public long UserId { get; set; } public string CardNumber { get; set; } public int PaymentMethodValue { get; set; } public string AdditionalInformation { get; set; } public virtual User User { get; set; } public PaymentMethod PaymentMethod { get { return (PaymentMethod)PaymentMethodValue; } set { PaymentMethodValue = (int)value; } } public State EntityState { get; set; } } public enum PaymentMethod { Cheque, Visa, MasterCard, PayPal, Diners } public enum BillingType { Pre, Post } public enum BillingPeriod { Weekly, Monthly, Yearly } public class Product : IObjectWithState { public long ProductId { get; set; } public string Name { get; set; } public string Description { get; set; } public string ProductType { get; set; } public double Price { get; set; } public State EntityState { get; set; } } public class User : IObjectWithState { public long UserId { get; set; } public long ContactInformationId { get; set; } public string Name { get; set; } public virtual IList PaymentInformation { get; set; } public virtual ContactInformation ContactInformation { get; set; } public State EntityState { get; set; } } public enum OrderState { Created, Active, Suspended, Overdue, Finished } public class Order : IObjectWithState { public long OrderId { get; set; } public long UserId { get; set; } public int StateValue { get; set; } public int BillingTypeValue { get; set; } public int BillingPeriodValue { get; set; } public DateTime? ActiveSince { get; set; } public DateTime? ActiveUntil { get; set; } public DateTime? LastBillableDay { get; set; } public DateTime? NextBillableDay { get; set; } public virtual User User { get; set; } public virtual IList Invoices { get; set; } public virtual IList OrderLines { get; set; } public OrderState State { get { return (OrderState)StateValue; } set { StateValue = (int)value; } } public BillingType BillingType { get { return (BillingType)BillingTypeValue; } set { BillingTypeValue = (int)value; } } public BillingPeriod BillingPeriod { get { return (BillingPeriod)BillingPeriodValue; } set { BillingPeriodValue = (int)value; } } public State EntityState { get; set; } } public class OrderLine : IObjectWithState { public long OrderLineId { get; set; } public long OrderId { get; set; } public long ProductId { get; set; } public int Quantity { get; set; } public double ProductPrice { get; set; } public virtual Order Order { get; set; } public virtual Product Product { get; set; } public State EntityState { get; set; } } public enum InvoiceStatus { Open, Overdue, Paid } public class Invoice : IObjectWithState { public long InvoiceId { get; set; } public long UserId { get; set; } public long OrderId { get; set; } public DateTime InvoiceDate { get; set; } public DateTime Due { get; set; } public int StatusValue { get; set; } public double SubTotal { get; set; } public double Total { get; set; } public double Tax { get; set; } public string InvoiceDocument { get; set; } public virtual User User { get; set; } public virtual Order Order { get; set; } public virtual IList InvoiceLines { get; set; } public InvoiceStatus Status { get { return (InvoiceStatus)StatusValue; } set { StatusValue = (int)value; } } public State EntityState { get; set; } } public class InvoiceLine : IObjectWithState { public long InvoiceLineId { get; set; } public long InvoiceId { get; set; } public long ProductId { get; set; } public int Quantity { get; set; } public double ProductPrice { get; set; } public virtual Invoice Invoice { get; set; } public virtual Product Product { get; set; } public State EntityState { get; set; } } public class UsageRecord : IObjectWithState { public long UsageRecordId { get; set; } public long UserId { get; set; } public long ProductId { get; set; } public DateTime Begin { get; set; } public DateTime End { get; set; } public int ServiceIdentifier { get; set; } public int ResourceIdentifier { get; set; } public virtual User User { get; set; } public virtual Product Product { get; set; } public State EntityState { get; set; } } }