Free cookie consent management tool by TermsFeed Policy Generator

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

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

#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 size: 2.5 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    #endregion
32
33    #region Order Methods
34
35    public void SaveOrder(Order order) {
36      //TODO: Authentication
37      //TODO: Enable Transaction
38      BillingDao.AddOrder(order);
39    }
40
41    public IList<Order> GetOrdersByState(OrderState state) {
42      //TODO: Authentication
43      //TODO: Enable Transaction
44      return BillingDao.FindOrderBy(order => order.State == state).ToList();
45    }
46
47    public IList<Order> GetOrders(string userName) {
48      //TODO: Authentication
49      //TODO: Enable Transaction
50      User user = GetUser(userName);
51      return BillingDao.FindOrderBy(order => order.User == user).ToList();
52    }
53
54    #endregion
55
56    #region User Methods
57
58    public User GetUser(string userName) {
59      //TODO: Authentication
60      //TODO: Enable Transaction
61      return BillingDao.FindUserBy(u => u.Name == userName).First();
62    }
63
64    public void SaveUser(User user) {
65      //TODO: Authentication
66      //TODO: Enable Transaction
67      BillingDao.AddUser(user);
68    }
69
70    #endregion
71
72    #region UsageRecords Methods
73
74    public IList<UsageRecord> GetUsageRecords(string userName) {
75      //TODO: Authentication
76      //TODO: Enable Transaction
77      User user = GetUser(userName);
78      return BillingDao.FindUsageRecordsBy(ur => ur.User == user).ToList();
79    }
80
81    #endregion
82
83    #region Invoice Methods
84
85    public IList<Invoice> GetInvoices(string userName) {
86      //TODO: Authentication
87      //TODO: Enable Transaction
88      User user = GetUser(userName);
89      return BillingDao.FindInvoiceBy(inv => inv.User == user).ToList();
90    }
91
92    #endregion
93  }
94}
Note: See TracBrowser for help on using the repository browser.