Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/BillingService.cs @ 9619

Last change on this file since 9619 was 9619, checked in by spimming, 11 years ago

#1888:

  • Added new BillingService methods
  • Disabled proxy generation and lazy loading!
  • Extended see method with additional test data
  • Added properties to order and invoice model
  • initial commit of BillingEngine module
File size: 3.0 KB
Line 
1using System.Collections.Generic;
2using System.Linq;
3using System.ServiceModel;
4using HeuristicLab.Services.Optimization.Billing.DataAccess;
5using HeuristicLab.Services.Optimization.Billing.Interfaces;
6using HeuristicLab.Services.Optimization.Billing.Model;
7
8namespace HeuristicLab.Services.Optimization.Billing.Business {
9  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
10  public class BillingService : IOptimizationBilling {
11    #region Properties
12
13    private BillingDao billingDao;
14    private BillingDao BillingDao {
15      get {
16        if (billingDao == null) billingDao = new BillingDao();
17        return billingDao;
18      }
19    }
20
21    #endregion
22
23    #region Product Methods
24
25    public IList<Product> GetProducts() {
26      //TODO: Authentication
27      //TODO: Enable Transaction
28      return BillingDao.FindAllProducts().ToList();
29    }
30
31    public IList<Product> GetProductByName(string productName) {
32      //TODO: Authentication
33      //TODO: Enable Transaction
34      return BillingDao.FindProdcutBy(prod => prod.Name == productName).ToList();
35    }
36
37    #endregion
38
39    #region Order Methods
40
41    public void SaveOrder(Order order) {
42      //TODO: Authentication
43      //TODO: Enable Transaction
44      BillingDao.AddOrder(order);
45    }
46
47    public IList<Order> GetOrdersByState(OrderState state) {
48      //TODO: Authentication
49      //TODO: Enable Transaction
50      return BillingDao.FindOrderBy(order => order.StateValue == (int)state).ToList();
51    }
52
53    public IList<Order> GetOrders(string userName) {
54      //TODO: Authentication
55      //TODO: Enable Transaction
56      User user = GetUser(userName);
57      return BillingDao.FindOrderBy(order => order.User == user).ToList();
58    }
59
60    public void UpdateOrder(Order order) {
61      throw new System.NotImplementedException();
62    }
63
64    #endregion
65
66    #region User Methods
67
68    public User GetUser(string userName) {
69      //TODO: Authentication
70      //TODO: Enable Transaction
71      return BillingDao.FindUserBy(u => u.Name == userName).First();
72    }
73
74    public void SaveUser(User user) {
75      //TODO: Authentication
76      //TODO: Enable Transaction
77      BillingDao.AddUser(user);
78    }
79
80    #endregion
81
82    #region UsageRecords Methods
83
84    public IList<UsageRecord> GetUsageRecords(string userName) {
85      //TODO: Authentication
86      //TODO: Enable Transaction
87      User user = GetUser(userName);
88      return BillingDao.FindUsageRecordsBy(ur => ur.User == user).ToList();
89    }
90
91    public IList<UsageRecord> GetUsageRecords(string username, System.DateTime from, System.DateTime to) {
92      throw new System.NotImplementedException();
93    }
94
95    #endregion
96
97    #region Invoice Methods
98
99    public IList<Invoice> GetInvoices(string userName) {
100      //TODO: Authentication
101      //TODO: Enable Transaction
102      User user = GetUser(userName);
103      return BillingDao.FindInvoiceBy(inv => inv.User == user).ToList();
104    }
105
106    #endregion
107  }
108}
Note: See TracBrowser for help on using the repository browser.