1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Services.Optimization.Billing.Interfaces;
|
---|
6 |
|
---|
7 | namespace 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 | }
|
---|