Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/DDLScript.sql
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/DDLScript.sql	(revision 9602)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/DDLScript.sql	(revision 9602)
@@ -0,0 +1,88 @@
+create table [dbo].[ContactInformations] (
+    [ContactInformationId] [bigint] not null identity,
+    [OrganizationName] [nvarchar](max) null,
+    [Street] [nvarchar](max) null,
+    [City] [nvarchar](max) null,
+    [State] [nvarchar](max) null,
+    [PostalCode] [nvarchar](max) null,
+    [LastName] [nvarchar](max) null,
+    [FirstName] [nvarchar](max) null,
+    [Email] [nvarchar](max) null,
+    primary key ([ContactInformationId])
+);
+create table [dbo].[Invoices] (
+    [InvoiceId] [bigint] not null identity,
+    [UserId] [bigint] not null,
+    [OrderId] [bigint] not null,
+    [Due] [datetime] not null,
+    [StatusValue] [int] not null,
+    [InvoiceDocument] [nvarchar](max) null,
+    primary key ([InvoiceId])
+);
+create table [dbo].[InvoiceLines] (
+    [InvoiceLineId] [bigint] not null identity,
+    [InvoiceId] [bigint] not null,
+    [ProductId] [bigint] not null,
+    [Quantity] [int] not null,
+    [ProductPrice] [float] not null,
+    primary key ([InvoiceLineId])
+);
+create table [dbo].[Orders] (
+    [OrderId] [bigint] not null identity,
+    [UserId] [bigint] not null,
+    [StateValue] [int] not null,
+    [BillingTypeValue] [int] not null,
+    [BillingPeriodValue] [int] not null,
+    [ActiveSince] [datetime] null,
+    [ActiveUntil] [datetime] null,
+    primary key ([OrderId])
+);
+create table [dbo].[OrderLines] (
+    [OrderLineId] [bigint] not null identity,
+    [OrderId] [bigint] not null,
+    [ProductId] [bigint] not null,
+    [Quantity] [int] not null,
+    [ProductPrice] [float] not null,
+    primary key ([OrderLineId])
+);
+create table [dbo].[PaymentInformations] (
+    [PaymentInformationId] [bigint] not null identity,
+    [UserId] [bigint] not null,
+    [CardNumber] [nvarchar](max) null,
+    [PaymentMethodValue] [int] not null,
+    [AdditionalInformation] [nvarchar](max) null,
+    primary key ([PaymentInformationId])
+);
+create table [dbo].[Products] (
+    [ProductId] [bigint] not null identity,
+    [Name] [nvarchar](max) null,
+    [Description] [nvarchar](max) null,
+    [ProductType] [nvarchar](max) null,
+    [Price] [float] not null,
+    primary key ([ProductId])
+);
+create table [dbo].[UsageRecords] (
+    [UsageRecordId] [bigint] not null identity,
+    [UserId] [bigint] not null,
+    [ProductId] [bigint] not null,
+    [Begin] [datetime] not null,
+    [End] [datetime] not null,
+    [ServiceIdentifier] [int] not null,
+    [ResourceIdentifier] [int] not null,
+    primary key ([UsageRecordId])
+);
+create table [dbo].[Users] (
+    [UserId] [bigint] not null identity,
+    [Name] [nvarchar](max) null,
+    primary key ([UserId])
+);
+alter table [dbo].[Invoices] add constraint [Invoice_Order] foreign key ([OrderId]) references [dbo].[Orders]([OrderId]);
+alter table [dbo].[Invoices] add constraint [Invoice_User] foreign key ([UserId]) references [dbo].[Users]([UserId]);
+alter table [dbo].[InvoiceLines] add constraint [InvoiceLine_Invoice] foreign key ([InvoiceId]) references [dbo].[Invoices]([InvoiceId]) on delete cascade;
+alter table [dbo].[InvoiceLines] add constraint [InvoiceLine_Product] foreign key ([ProductId]) references [dbo].[Products]([ProductId]);
+alter table [dbo].[Orders] add constraint [Order_User] foreign key ([UserId]) references [dbo].[Users]([UserId]);
+alter table [dbo].[OrderLines] add constraint [OrderLine_Order] foreign key ([OrderId]) references [dbo].[Orders]([OrderId]) on delete cascade;
+alter table [dbo].[OrderLines] add constraint [OrderLine_Product] foreign key ([ProductId]) references [dbo].[Products]([ProductId]);
+alter table [dbo].[UsageRecords] add constraint [UsageRecord_Product] foreign key ([ProductId]) references [dbo].[Products]([ProductId]);
+alter table [dbo].[UsageRecords] add constraint [UsageRecord_User] foreign key ([UserId]) references [dbo].[Users]([UserId]);
+alter table [dbo].[PaymentInformations] add constraint [User_PaymentInformation] foreign key ([UserId]) references [dbo].[Users]([UserId]);
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj	(revision 9602)
@@ -62,4 +62,7 @@
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="DDLScript.sql" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs	(revision 9602)
@@ -1,3 +1,5 @@
 ﻿using System;
+using System.Data.Entity.Infrastructure;
+using System.IO;
 using HeuristicLab.Services.Optimization.Billing.DataAccess;
 using HeuristicLab.Services.Optimization.Billing.Model;
@@ -6,6 +8,12 @@
   class Program {
     static void Main(string[] args) {
+      string ddlScript;
       using (var context = new BillingContext()) {
         System.Data.Entity.Database.SetInitializer(new HeuristicLab.Services.Optimization.Billing.DataAccess.BillingContext.BillingContextInitiliazer());
+        ddlScript = (((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript());
+      }
+
+      using (StreamWriter writer = new StreamWriter(@"..\..\DDLScript.sql")) {
+        writer.Write(ddlScript);
       }
 
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/BillingService.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/BillingService.cs	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/BillingService.cs	(revision 9602)
@@ -45,29 +45,50 @@
     }
 
+    public IList<Order> GetOrders(string userName) {
+      //TODO: Authentication
+      //TODO: Enable Transaction
+      User user = GetUser(userName);
+      return BillingDao.FindOrderBy(order => order.User == user).ToList();
+    }
+
     #endregion
 
-
-    public IList<Order> GetOrders(string userName) {
-      throw new System.NotImplementedException();
-    }
-
+    #region User Methods
 
     public User GetUser(string userName) {
-      throw new System.NotImplementedException();
+      //TODO: Authentication
+      //TODO: Enable Transaction
+      return BillingDao.FindUserBy(u => u.Name == userName).First();
     }
 
     public void SaveUser(User user) {
-      throw new System.NotImplementedException();
+      //TODO: Authentication
+      //TODO: Enable Transaction
+      BillingDao.AddUser(user);
     }
 
+    #endregion
+
+    #region UsageRecords Methods
 
     public IList<UsageRecord> GetUsageRecords(string userName) {
-      throw new System.NotImplementedException();
+      //TODO: Authentication
+      //TODO: Enable Transaction
+      User user = GetUser(userName);
+      return BillingDao.FindUsageRecordsBy(ur => ur.User == user).ToList();
     }
 
+    #endregion
+
+    #region Invoice Methods
 
     public IList<Invoice> GetInvoices(string userName) {
-      throw new System.NotImplementedException();
+      //TODO: Authentication
+      //TODO: Enable Transaction
+      User user = GetUser(userName);
+      return BillingDao.FindInvoiceBy(inv => inv.User == user).ToList();
     }
+
+    #endregion
   }
 }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/MockupBillingService.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/MockupBillingService.cs	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/MockupBillingService.cs	(revision 9602)
@@ -1,6 +1,6 @@
-﻿using System.Collections.Generic;
+﻿using System;
+using System.Collections.Generic;
 using System.Linq;
 using HeuristicLab.Services.Optimization.Billing.Interfaces;
-using System;
 
 namespace HeuristicLab.Services.Optimization.Billing.Business {
@@ -69,9 +69,7 @@
         orders.Add(order);
         allOrders.Add(order);
-      }
-      else {
+      } else {
         oldOrder.Invoices = order.Invoices;
         oldOrder.OrderLines = order.OrderLines;
-        oldOrder.OrderStateId = order.OrderStateId;
         oldOrder.State = order.State;
         oldOrder.ActiveSince = order.ActiveSince;
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs	(revision 9602)
@@ -1,3 +1,5 @@
-﻿using System.Data.Entity;
+﻿using System;
+using System.Collections.Generic;
+using System.Data.Entity;
 using System.Data.Entity.ModelConfiguration;
 using System.Data.Entity.ModelConfiguration.Conventions;
@@ -6,5 +8,4 @@
 namespace HeuristicLab.Services.Optimization.Billing.DataAccess {
   public class BillingContext : DbContext {
-    public DbSet<ContactInformation> ContactInformations { get; set; }
     public DbSet<Product> Products { get; set; }
     public DbSet<User> Users { get; set; }
@@ -14,4 +15,6 @@
     public DbSet<InvoiceLine> InvoiceLines { get; set; }
     public DbSet<UsageRecord> UsageRecords { get; set; }
+    public DbSet<ContactInformation> ContactInformations { get; set; }
+    public DbSet<PaymentInformation> PaymentInformations { get; set; }
 
     // enum PaymentMethod
@@ -19,5 +22,5 @@
 
     public BillingContext()
-      : base("name=BillingContext") {
+      : this("name=BillingContext") {
 
     }
@@ -34,4 +37,5 @@
       modelBuilder.Configurations.Add(new InvoiceLineConfiguration());
       modelBuilder.Configurations.Add(new UsageRecordConfiguration());
+      modelBuilder.Configurations.Add(new UserConfiguration());
 
       modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
@@ -77,11 +81,19 @@
     }
 
+    private class UserConfiguration : EntityTypeConfiguration<User> {
+      internal UserConfiguration() {
+        this.HasMany(u => u.PaymentInformation).WithRequired(pi => pi.User).HasForeignKey(pi => pi.UserId);
+      }
+    }
+
     #endregion
 
     #region DB Seed Methods
 
-    public class BillingContextInitiliazer : DropCreateDatabaseIfModelChanges<BillingContext> {
+    // - DropCreateDatabaseAlways<BillingContext>
+    // - DropCreateDatabaseIfModelChanges<BillingContext>
+    public class BillingContextInitiliazer : DropCreateDatabaseAlways<BillingContext> {
       protected override void Seed(BillingContext context) {
-        context.Products.Add(new Model.Product() {
+        Product p1 = new Product() {
           Name = "Optimization-as-a-Service - Experiment execution",
           Description = "Create and run your experiments within HeuristicLab Hive",
@@ -89,5 +101,51 @@
           Price = 10.0,
           ProductType = "Optimization Service"
-        });
+        };
+        p1 = context.Products.Add(p1);
+
+        User u1 = new Model.User() { Name = "spimming" };
+        User u2 = new Model.User() {
+          Name = "fschoeppl",
+          PaymentInformation = new List<PaymentInformation>() { 
+            new PaymentInformation() { 
+              PaymentMethod = PaymentMethod.Visa, 
+              CardNumber = "123456789" } }
+        };
+
+        u1 = context.Users.Add(u1);
+        u2 = context.Users.Add(u2);
+
+        ContactInformation ci1 = new ContactInformation() {
+          FirstName = "Max",
+          LastName = "Mustermann",
+          Email = "max.mustermann@fh-hagenberg.at",
+          OrganizationName = "University of Applied Sciences Upper Austria School of Informatics/Communications/Media",
+          Street = "Softwarepark 11",
+          PostalCode = "4232",
+          City = "Hagenberg"
+        };
+
+        ci1 = context.ContactInformations.Add(ci1);
+
+        Order o1 = new Order() {
+          User = u2,
+          State = OrderState.Created,
+          BillingType = BillingType.Post,
+          BillingPeriod = BillingPeriod.Monthly,
+        };
+        OrderLine ol1 = new OrderLine() {
+          Order = o1,
+          Product = p1,
+          ProductPrice = p1.Price,
+          Quantity = 1
+        };
+        o1 = context.Orders.Add(o1);
+        ol1 = context.OrderLines.Add(ol1);
+
+        context.SaveChanges();
+
+        o1.State = OrderState.Active;
+        o1.ActiveSince = DateTime.Now;
+        context.Entry(o1).State = System.Data.EntityState.Modified;
         context.SaveChanges();
       }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingDao.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingDao.cs	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingDao.cs	(revision 9602)
@@ -111,4 +111,157 @@
 
     #endregion
+
+    #region OrderLine Methods
+
+    public OrderLine FindOrderLineById(long id) {
+      return ExecuteWithContext<OrderLine>((context) => {
+        return context.OrderLines.FirstOrDefault(ol => ol.OrderLineId == id);
+      });
+    }
+
+    public IEnumerable<OrderLine> FindOrderLineBy(Expression<Func<OrderLine, bool>> predicate) {
+      using (var context = CreateContext()) {
+        var orderLines = context.OrderLines.Where(predicate).ToList();
+        return orderLines;
+      }
+    }
+
+    public IEnumerable<OrderLine> FindAllOrderLines() {
+      using (var context = CreateContext()) {
+        var orderLines = context.OrderLines.ToList();
+        return orderLines;
+      }
+    }
+
+    public void AddOrderLine(OrderLine entity) {
+      ExecuteWithContext((context) => {
+        context.OrderLines.Add(entity);
+        context.SaveChanges();
+      });
+    }
+
+    public void UpdateOrderLine(OrderLine entity) {
+      ExecuteWithContext((context) => {
+        context.OrderLines.Attach(entity);
+        context.Entry(entity).State = System.Data.EntityState.Modified;
+        context.SaveChanges();
+      });
+    }
+
+    void DeleteOrderLine(OrderLine entity) {
+      ExecuteWithContext((context) => {
+        context.OrderLines.Remove(entity);
+      });
+    }
+
+    #endregion
+
+    #region User Methods
+
+    public User FindUserById(long id) {
+      return ExecuteWithContext<User>((context) => {
+        return context.Users.FirstOrDefault(user => user.UserId == id);
+      });
+    }
+
+    public IEnumerable<User> FindUserBy(Expression<Func<User, bool>> predicate) {
+      using (var context = CreateContext()) {
+        var users = context.Users.Where(predicate).ToList();
+        return users;
+      }
+    }
+
+    public IEnumerable<User> FindAllUsers() {
+      using (var context = CreateContext()) {
+        var users = context.Users.ToList();
+        return users;
+      }
+    }
+
+    public void AddUser(User entity) {
+      ExecuteWithContext((context) => {
+        context.Users.Add(entity);
+        context.SaveChanges();
+      });
+    }
+
+    public void UpdateUser(User entity) {
+      ExecuteWithContext((context) => {
+        context.Users.Attach(entity);
+        context.Entry(entity).State = System.Data.EntityState.Modified;
+        context.SaveChanges();
+      });
+    }
+
+    void DeleteUser(User entity) {
+      ExecuteWithContext((context) => {
+        context.Users.Remove(entity);
+      });
+    }
+
+    #endregion
+
+    #region UsageRecords Methods
+
+    public UsageRecord FindUsageRecordById(long id) {
+      return ExecuteWithContext<UsageRecord>((context) => {
+        return context.UsageRecords.FirstOrDefault(prod => prod.ProductId == id);
+      });
+    }
+
+    public IEnumerable<UsageRecord> FindUsageRecordsBy(Expression<Func<UsageRecord, bool>> predicate) {
+      using (var context = CreateContext()) {
+        var records = context.UsageRecords.Where(predicate).ToList();
+        return records;
+      }
+    }
+
+    public IEnumerable<UsageRecord> FindAllUsageRecords() {
+      using (var context = CreateContext()) {
+        var records = context.UsageRecords.ToList();
+        return records;
+      }
+    }
+
+    public void AddUsageRecord(UsageRecord entity) {
+      ExecuteWithContext((context) => {
+        context.UsageRecords.Add(entity);
+        context.SaveChanges();
+      });
+    }
+
+    public void UpdateUsageRecord(UsageRecord entity) {
+      ExecuteWithContext((context) => {
+        context.UsageRecords.Attach(entity);
+        context.Entry(entity).State = System.Data.EntityState.Modified;
+        context.SaveChanges();
+      });
+    }
+
+    void DeleteUsageRecord(UsageRecord entity) {
+      ExecuteWithContext((context) => {
+        context.UsageRecords.Remove(entity);
+      });
+    }
+
+    #endregion
+
+    #region Invoice Methods
+
+    public void AddInvoice(Invoice entity) {
+      ExecuteWithContext((context) => {
+        context.Invoices.Add(entity);
+        context.SaveChanges();
+      });
+    }
+
+    public IEnumerable<Invoice> FindInvoiceBy(Expression<Func<Invoice, bool>> predicate) {
+      using (var context = CreateContext()) {
+        var invoices = context.Invoices.Where(predicate).ToList();
+        return invoices;
+      }
+    }
+
+    #endregion
   }
 }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/HeuristicLab.Services.Optimization.Billing.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/HeuristicLab.Services.Optimization.Billing.csproj	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/HeuristicLab.Services.Optimization.Billing.csproj	(revision 9602)
@@ -37,4 +37,5 @@
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
     <Reference Include="System.Data.Entity" />
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs	(revision 9588)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs	(revision 9602)
@@ -1,6 +1,17 @@
-﻿using System;
+﻿
+using System;
 using System.Collections.Generic;
+namespace HeuristicLab.Services.Optimization.Billing.Model {
 
-namespace HeuristicLab.Services.Optimization.Billing.Model {
+  /*
+   * Note: enum support 
+   * Although we use EF5 enums are not supported as we target .NET 4.0.
+   * Therefor 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 {
     public long ContactInformationId { get; set; }
@@ -17,7 +28,15 @@
   public class PaymentInformation {
     public long PaymentInformationId { get; set; }
+    public long UserId { get; set; }
     public string CardNumber { get; set; }
-    public PaymentMethod PaymentMethod { 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; }
+    }
   }
 
@@ -52,5 +71,7 @@
     public long UserId { get; set; }
     public string Name { get; set; }
+
     public virtual IList<PaymentInformation> PaymentInformation { get; set; }
+
   }
 
@@ -66,15 +87,26 @@
     public long OrderId { get; set; }
     public long UserId { get; set; }
-    public BillingType BillingType { get; set; }
-    public long OrderStateId { get; set; }
-    public BillingPeriod BillingPeriod { 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 virtual User User { get; set; }
-    public virtual OrderState State { get; set; }
     public virtual IList<Invoice> Invoices { get; set; }
     public virtual IList<OrderLine> 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; }
+    }
   }
 
@@ -99,5 +131,5 @@
     public long OrderId { get; set; }
     public DateTime Due { get; set; }
-    public InvoiceStatus Status { get; set; }
+    public int StatusValue { get; set; }
     public string InvoiceDocument { get; set; }
 
@@ -105,4 +137,9 @@
     public virtual Order Order { get; set; }
     public virtual IList<InvoiceLine> InvoiceLines { get; set; }
+
+    public InvoiceStatus Status {
+      get { return (InvoiceStatus)StatusValue; }
+      set { StatusValue = (int)value; }
+    }
   }
 
