Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/10/13 16:32:19 (11 years ago)
Author:
spimming
Message:

#1888:

  • Workaround for enums in model classes
  • Implemented dao methods for model
  • Added test data in db seed method
  • changed EF configuration
  • Implemented some BL methods
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs

    r9586 r9602  
    1 using System;
     1
     2using System;
    23using System.Collections.Generic;
     4namespace HeuristicLab.Services.Optimization.Billing.Model {
    35
    4 namespace HeuristicLab.Services.Optimization.Billing.Model {
     6  /*
     7   * Note: enum support
     8   * Although we use EF5 enums are not supported as we target .NET 4.0.
     9   * Therefor we use the following workaround:
     10   * Just create an int property on your class to represent the int value of the enum.
     11   * That's the property that EF should map, then have a "mini wrapper" property to allow you to use the enum
     12   * For example see class PaymentInformation
     13   * See also: http://stackoverflow.com/questions/6344032/enums-with-ef-code-first-standard-method-to-seeding-db-and-then-using
     14   */
     15
    516  public class ContactInformation {
    617    public long ContactInformationId { get; set; }
     
    1728  public class PaymentInformation {
    1829    public long PaymentInformationId { get; set; }
     30    public long UserId { get; set; }
    1931    public string CardNumber { get; set; }
    20     public PaymentMethod PaymentMethod { get; set; }
     32    public int PaymentMethodValue { get; set; }
    2133    public string AdditionalInformation { get; set; }
     34
     35    public virtual User User { get; set; }
     36
     37    public PaymentMethod PaymentMethod {
     38      get { return (PaymentMethod)PaymentMethodValue; }
     39      set { PaymentMethodValue = (int)value; }
     40    }
    2241  }
    2342
     
    5271    public long UserId { get; set; }
    5372    public string Name { get; set; }
     73
    5474    public virtual IList<PaymentInformation> PaymentInformation { get; set; }
     75
    5576  }
    5677
     
    6687    public long OrderId { get; set; }
    6788    public long UserId { get; set; }
    68     public BillingType BillingType { get; set; }
    69     public long OrderStateId { get; set; }
    70     public BillingPeriod BillingPeriod { get; set; }
     89    public int StateValue { get; set; }
     90    public int BillingTypeValue { get; set; }
     91    public int BillingPeriodValue { get; set; }
    7192    public DateTime? ActiveSince { get; set; }
    7293    public DateTime? ActiveUntil { get; set; }
    7394
    74 
    7595    public virtual User User { get; set; }
    76     public virtual OrderState State { get; set; }
    7796    public virtual IList<Invoice> Invoices { get; set; }
    7897    public virtual IList<OrderLine> OrderLines { get; set; }
     98
     99    public OrderState State {
     100      get { return (OrderState)StateValue; }
     101      set { StateValue = (int)value; }
     102    }
     103    public BillingType BillingType {
     104      get { return (BillingType)BillingTypeValue; }
     105      set { BillingTypeValue = (int)value; }
     106    }
     107    public BillingPeriod BillingPeriod {
     108      get { return (BillingPeriod)BillingPeriodValue; }
     109      set { BillingPeriodValue = (int)value; }
     110    }
    79111  }
    80112
     
    99131    public long OrderId { get; set; }
    100132    public DateTime Due { get; set; }
    101     public InvoiceStatus Status { get; set; }
     133    public int StatusValue { get; set; }
    102134    public string InvoiceDocument { get; set; }
    103135
     
    105137    public virtual Order Order { get; set; }
    106138    public virtual IList<InvoiceLine> InvoiceLines { get; set; }
     139
     140    public InvoiceStatus Status {
     141      get { return (InvoiceStatus)StatusValue; }
     142      set { StatusValue = (int)value; }
     143    }
    107144  }
    108145
Note: See TracChangeset for help on using the changeset viewer.