- Timestamp:
- 06/04/13 16:30:39 (11 years ago)
- Location:
- branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/BillingService.cs
r9577 r9582 46 46 47 47 #endregion 48 49 50 public IList<Order> GetOrders(string userName) { 51 throw new System.NotImplementedException(); 52 } 53 54 55 public User GetUser(string userName) { 56 throw new System.NotImplementedException(); 57 } 58 59 public void SaveUser(User user) { 60 throw new System.NotImplementedException(); 61 } 48 62 } 49 63 } -
branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/MockupBillingService.cs
r9577 r9582 9 9 private static IDictionary<string, IList<Model.Order>> userToOrders; 10 10 private static IList<Model.Order> allOrders; 11 private static IDictionary<string, Model.User> users; 12 private static long maxId = 1; 11 13 12 14 static MockupBillingService() { … … 29 31 userToOrders = new Dictionary<string, IList<Model.Order>>(); 30 32 allOrders = new List<Model.Order>(); 33 users = new Dictionary<string, Model.User>(); 31 34 } 32 35 … … 38 41 IList<Model.Order> orders; 39 42 if (!userToOrders.TryGetValue(order.User.Name, out orders)) { 40 userToOrders[order.User.Name] = orders = new List<Model.Order>(); 43 userToOrders[order.User.Name] = orders = new List<Model.Order>(); 41 44 } 42 orders.Add(order); 43 allOrders.Add(order); 45 var oldOrder = (from o in orders where o.OrderId == order.OrderId select o).FirstOrDefault(); 46 if (oldOrder == null) { 47 order.OrderId = maxId++; 48 orders.Add(order); 49 allOrders.Add(order); 50 } 51 else { 52 oldOrder.Invoices = order.Invoices; 53 oldOrder.OrderLines = order.OrderLines; 54 oldOrder.OrderStateId = order.OrderStateId; 55 oldOrder.State = order.State; 56 oldOrder.ActiveSince = order.ActiveSince; 57 oldOrder.ActiveUntil = order.ActiveUntil; 58 oldOrder.BillingPeriod = order.BillingPeriod; 59 oldOrder.BillingType = order.BillingType; 60 } 44 61 } 45 62 … … 47 64 return (from o in allOrders where o.State == state select o).ToList(); 48 65 } 66 67 68 public IList<Model.Order> GetOrders(string userName) { 69 return (from o in allOrders where o.User.Name == userName select o).ToList(); 70 } 71 72 73 public Model.User GetUser(string userName) { 74 Model.User user; 75 if (!users.TryGetValue(userName, out user)) 76 return null; 77 return user; 78 } 79 80 public void SaveUser(Model.User user) { 81 users[user.Name] = user; 82 } 49 83 } 50 84 }
Note: See TracChangeset
for help on using the changeset viewer.