Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Billing/MockupOptimizationBilling.cs @ 9556

Last change on this file since 9556 was 9556, checked in by fschoepp, 11 years ago

#1888:

  • Added views for the billing component (Register users, Create orders and Activate Orders view)
  • Added a mockup for the billing back-end .
File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Services.Optimization.Billing.Interfaces;
6
7namespace HeuristicLab.Services.Optimization.Billing {
8  public class MockupOptimizationBilling : IOptimizationBilling {
9   
10    private static IList<Model.Product> products;
11    private static IDictionary<string, IList<Model.Order>> userToOrders;
12    private static IList<Model.Order> allOrders;
13
14    static MockupOptimizationBilling() {
15      products = new List<Model.Product>();
16      products.Add(new Model.Product() {
17        Name = "Optimization-as-a-Service - Experiment execution",
18        Description = "Create and run your experiments within HeuristicLab Hive",
19        Id = 1,
20        Price = 10.0,
21        ProductType = "Optimization Service"
22      });
23      products.Add(new Model.Product() {
24        Name = "Whatever-o-matic - Experiment execution",
25        Description = "Another fine product",
26        Id = 2,
27        Price = 100.0,
28        ProductType = "Product"
29      });
30
31      userToOrders = new Dictionary<string, IList<Model.Order>>();
32      allOrders = new List<Model.Order>();
33    }
34
35    public IList<Model.Product> GetProducts() {
36      return products;
37    }
38
39    public void SaveOrder(Model.Order order) {
40      IList<Model.Order> orders;
41      if (!userToOrders.TryGetValue(order.User.Name, out orders)) {
42        userToOrders[order.User.Name] = orders = new List<Model.Order>();
43      }
44      orders.Add(order);
45      allOrders.Add(order);
46    }
47
48    public IList<Model.Order> GetOrdersByState(Model.OrderState state) {
49      return (from o in allOrders where o.State == state select o).ToList();
50    }
51  }
52}
Note: See TracBrowser for help on using the repository browser.