Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9576


Ignore:
Timestamp:
06/04/13 10:59:03 (12 years ago)
Author:
spimming
Message:

#1888:

  • Added billing test client
  • Use entity framework for DAL
  • Modified service interface and model classes
Location:
branches/OaaS
Files:
6 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab 3.3 Services.sln

    r9556 r9576  
    7171EndProject
    7272Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.Optimization.Billing", "HeuristicLab.Services.Optimization.Billing\HeuristicLab.Services.Optimization.Billing.csproj", "{5DC3E4F1-E21B-4C18-8921-88058E86FB07}"
     73EndProject
     74Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Services.Optimization.Billing.Test", "HeuristicLab.Services.Optimization.Billing.Test\HeuristicLab.Services.Optimization.Billing.Test.csproj", "{07D84A1D-56B7-4A8A-87EF-303A8518D48C}"
    7375EndProject
    7476Global
     
    374376    {5DC3E4F1-E21B-4C18-8921-88058E86FB07}.Release|x64.ActiveCfg = Release|Any CPU
    375377    {5DC3E4F1-E21B-4C18-8921-88058E86FB07}.Release|x86.ActiveCfg = Release|Any CPU
     378    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Any CPU.ActiveCfg = Debug|x86
     379    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
     380    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.Build.0 = Debug|x86
     381    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|x64.ActiveCfg = Debug|x86
     382    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|x86.ActiveCfg = Debug|x86
     383    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|x86.Build.0 = Debug|x86
     384    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Release|Any CPU.ActiveCfg = Release|x86
     385    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Release|Mixed Platforms.ActiveCfg = Release|x86
     386    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Release|Mixed Platforms.Build.0 = Release|x86
     387    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Release|x64.ActiveCfg = Release|x86
     388    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Release|x86.ActiveCfg = Release|x86
     389    {07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Release|x86.Build.0 = Release|x86
    376390  EndGlobalSection
    377391  GlobalSection(SolutionProperties) = preSolution
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/HeuristicLab.Services.Optimization.Billing.csproj

    r9556 r9576  
    3232  </PropertyGroup>
    3333  <ItemGroup>
     34    <Reference Include="EntityFramework">
     35      <HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath>
     36    </Reference>
    3437    <Reference Include="System" />
     38    <Reference Include="System.ComponentModel.DataAnnotations" />
    3539    <Reference Include="System.Core" />
     40    <Reference Include="System.Data.Entity" />
    3641    <Reference Include="System.ServiceModel" />
    3742    <Reference Include="System.Xml.Linq" />
     
    4247  </ItemGroup>
    4348  <ItemGroup>
     49    <Compile Include="Business\BillingService.cs" />
     50    <Compile Include="Business\BillingServiceProvider.cs" />
     51    <Compile Include="DataAccess\BillingContext.cs" />
     52    <Compile Include="DataAccess\BillingDao.cs" />
     53    <Compile Include="Interfaces\IEntity.cs" />
     54    <Compile Include="Interfaces\IGenericDao.cs" />
    4455    <Compile Include="Interfaces\IOptimizationBilling.cs" />
    45     <Compile Include="MockupOptimizationBilling.cs" />
     56    <Compile Include="Business\MockupBillingService.cs" />
    4657    <Compile Include="Model\Model.cs" />
    4758    <Compile Include="Properties\AssemblyInfo.cs" />
    4859  </ItemGroup>
     60  <ItemGroup>
     61    <None Include="App.config" />
     62    <None Include="packages.config" />
     63  </ItemGroup>
     64  <ItemGroup />
    4965  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    5066  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Interfaces/IOptimizationBilling.cs

    r9551 r9576  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1using System.Collections.Generic;
     2using System.Net.Security;
    53using System.ServiceModel;
    6 using System.Net.Security;
    74using HeuristicLab.Services.Optimization.Billing.Model;
    85
     
    107  [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)]
    118  public interface IOptimizationBilling {
     9    [OperationContract]
    1210    IList<Product> GetProducts();
     11
    1312    // payment methods via enumeration
     13
     14    [OperationContract]
    1415    void SaveOrder(Order order);
     16
     17    [OperationContract]
    1518    IList<Order> GetOrdersByState(OrderState state);
    1619  }
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs

    r9558 r9576  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    53
    64namespace HeuristicLab.Services.Optimization.Billing.Model {
    75  public class ContactInformation {
    8     public long Id { get; set; }
     6    public long ContactInformationId { get; set; }
    97    public string OrganizationName { get; set; }
    108    public string Street { get; set; }
     
    2624
    2725  public class Product {
    28     public long Id { get; set; }
     26    public long ProductId { get; set; }
    2927    public string Name { get; set; }
    3028    public string Description { get; set; }
     
    3432
    3533  public class User {
     34    public long UserId { get; set; }
    3635    public string Name { get; set; }
    3736  }
     
    4645
    4746  public class Order {
    48     public long Id { get; set; }
    49     public User User { get; set; }
     47    public long OrderId { get; set; }
     48    public long UserId { get; set; }
    5049    public string BillingType { get; set; }
    51     public OrderState State { get; set; }
     50    public long OrderStateId { get; set; }
    5251    public string BillingPeriod { get; set; }
    5352    public DateTime ActiveSince { get; set; }
    5453    public DateTime ActiveUntil { get; set; }
    55     public IList<Invoice> Invoices { get; set; }
    56     public IList<OrderLine> OrderLines { get; set; }
     54
     55
     56    public virtual User User { get; set; }
     57    public virtual OrderState State { get; set; }
     58    public virtual IList<Invoice> Invoices { get; set; }
     59    public virtual IList<OrderLine> OrderLines { get; set; }
    5760  }
    5861
    5962  public class OrderLine {
    60     public long Id { get; set; }
    61     public Order Order { get; set; }
    62     public Product Product { get; set; }
     63    public long OrderLineId { get; set; }
     64    public long OrderId { get; set; }
     65    public long ProductId { get; set; }
    6366    public int Quantity { get; set; }
    6467    public double ProductPrice { get; set; }
     68
     69    public virtual Order Order { get; set; }
     70    public virtual Product Product { get; set; }
    6571  }
    6672
    6773  public class Invoice {
    68     public long Id { get; set; }
    69     public User User { get; set; }
     74    public long InvoiceId { get; set; }
     75    public long UserId { get; set; }
     76    public long OrderId { get; set; }
    7077    public DateTime Due { get; set; }
    7178    public string Status { get; set; }
    7279    public string InvoiceDocument { get; set; }
    73     public Order Order { get; set; }
     80
     81    public virtual User User { get; set; }
     82    public virtual Order Order { get; set; }
    7483  }
    7584
    7685  public class InvoiceLine {
    77     public long Id { get; set; }
    78     public Invoice Invoice { get; set; }
    79     public Product Product { get; set; }
     86    public long InvoiceLineId { get; set; }
     87    public long InvoiceId { get; set; }
     88    public long ProductId { get; set; }
    8089    public int Quantity { get; set; }
    8190    public double ProductPrice { get; set; }
     91
     92    public virtual Invoice Invoice { get; set; }
     93    public virtual Product Product { get; set; }
    8294  }
    8395
    84   public class Usage {
    85     public long Id { get; set; }
    86     public User User { get; set; }
    87     public IList<UsageLine> UsageLines { get; set; }
     96  public class UsageRecord {
     97    public long UsageRecordId { get; set; }
     98    public long UserId { get; set; }
     99
     100    public virtual User User { get; set; }
     101    public virtual IList<UsageRecordLine> UsageRecordLines { get; set; }
    88102  }
    89103
    90   public class UsageLine {
    91     public long Id { get; set; }
    92     public Usage Usage { get; set; }
     104  public class UsageRecordLine {
     105    public long UsageRecordLineId { get; set; }
     106    public long UsageRecordId { get; set; }
    93107    public DateTime Begin { get; set; }
    94108    public DateTime End { get; set; }
     109
     110    public virtual UsageRecord UsageRecord { get; set; }
    95111  }
    96112}
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OrderAdminController.cs

    r9558 r9576  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Web;
     1using System.Linq;
    52using System.Web.Mvc;
     3using HeuristicLab.Services.Optimization.Billing.Business;
     4using HeuristicLab.Services.Optimization.Billing.Interfaces;
    65using HeuristicLab.Services.Optimization.Web.Models;
    7 using HeuristicLab.Services.Optimization.Billing.Interfaces;
    8 using HeuristicLab.Services.Optimization.Billing;
    96
    10 namespace HeuristicLab.Services.Optimization.Web.Controllers
    11 {
    12     [Authorize(Roles = "Web User")]
    13     public class OrderAdminController : Controller
    14     {
    15         private IOptimizationBilling billing = new MockupOptimizationBilling();
     7namespace HeuristicLab.Services.Optimization.Web.Controllers {
     8  [Authorize(Roles = "Web User")]
     9  public class OrderAdminController : Controller {
     10    private IOptimizationBilling billing = BillingServiceProvider.Instance;
    1611
    17         //
    18         // GET: /OrderAdmin/
     12    //
     13    // GET: /OrderAdmin/
    1914
    20         public ActionResult Index()
    21         {
    22             var orders = billing.GetOrdersByState(Billing.Model.OrderState.Created);
    23             return View(new OrderAdminModel() { Orders = orders });
    24         }
     15    public ActionResult Index() {
     16      var orders = billing.GetOrdersByState(Billing.Model.OrderState.Created);
     17      return View(new OrderAdminModel() { Orders = orders });
     18    }
    2519
    26         [HttpPost]
    27         public ActionResult ActivateOrder(OrderAdminModel model) {
    28           var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.Id == model.OrderId select o).FirstOrDefault();
    29           order.State = Billing.Model.OrderState.Active;
    30           // TODO: Probably activate order via different method
    31           billing.SaveOrder(order);
    32           return RedirectToAction("Index");
    33         }
     20    [HttpPost]
     21    public ActionResult ActivateOrder(OrderAdminModel model) {
     22      var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.OrderId == model.OrderId select o).FirstOrDefault();
     23      order.State = Billing.Model.OrderState.Active;
     24      // TODO: Probably activate order via different method
     25      billing.SaveOrder(order);
     26      return RedirectToAction("Index");
     27    }
    3428
    35     }
     29  }
    3630}
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OrderController.cs

    r9558 r9576  
    1 using System;
    2 using System.Collections.Generic;
     1using System.Collections.Generic;
    32using System.Linq;
    4 using System.Web;
    53using System.Web.Mvc;
     4using System.Web.Security;
     5using HeuristicLab.Services.Optimization.Billing.Business;
     6using HeuristicLab.Services.Optimization.Billing.Interfaces;
     7using HeuristicLab.Services.Optimization.Billing.Model;
    68using HeuristicLab.Services.Optimization.Web.Models;
    7 using HeuristicLab.Services.Optimization.Billing.Model;
    8 using HeuristicLab.Services.Optimization.Billing.Interfaces;
    9 using HeuristicLab.Services.Optimization.Billing;
    10 using System.Web.Security;
    119
    12 namespace HeuristicLab.Services.Optimization.Web.Controllers
    13 {
    14     [Authorize(Roles = "Web User")]
    15     public class OrderController : Controller
    16     {
    17         private IOptimizationBilling billing = new MockupOptimizationBilling();
     10namespace HeuristicLab.Services.Optimization.Web.Controllers {
     11  [Authorize(Roles = "Web User")]
     12  public class OrderController : Controller {
     13    private IOptimizationBilling billing = BillingServiceProvider.Instance;
    1814
    19         //
    20         // GET: /Order/
     15    //
     16    // GET: /Order/
    2117
    22         public ActionResult Index()
    23         {
    24           return CreateOrder(new OrderModel()); //View();
    25         }
     18    public ActionResult Index() {
     19      return CreateOrder(new OrderModel()); //View();
     20    }
    2621
    2722
    28         [HttpPost]
    29         public ActionResult CreateOrder(OrderModel model) {
    30           Session["order"] = model;
    31           return AddProduct();
    32         }
     23    [HttpPost]
     24    public ActionResult CreateOrder(OrderModel model) {
     25      Session["order"] = model;
     26      return AddProduct();
     27    }
    3328
    34         public ActionResult AddProduct() {
    35           return View("AddProduct", new ProductsModel() { Products = billing.GetProducts() });
    36         }
     29    public ActionResult AddProduct() {
     30      return View("AddProduct", new ProductsModel() { Products = billing.GetProducts() });
     31    }
    3732
    38         [HttpPost]
    39         public ActionResult AddProduct(ProductsModel product) {
    40           var order = Session["order"] as OrderModel;
    41           var prod = (from b in billing.GetProducts()
    42                       where b.Id == product.ProductId
    43                       select b).FirstOrDefault();
    44           order.ProductQuantities[prod.Id] = product.Quantity;
    45           return AddProduct();
    46         }
     33    [HttpPost]
     34    public ActionResult AddProduct(ProductsModel product) {
     35      var order = Session["order"] as OrderModel;
     36      var prod = (from b in billing.GetProducts()
     37                  where b.ProductId == product.ProductId
     38                  select b).FirstOrDefault();
     39      order.ProductQuantities[prod.ProductId] = product.Quantity;
     40      return AddProduct();
     41    }
    4742
    48         public ActionResult SaveOrder() {
    49           var orderModel = Session["order"] as OrderModel;
    50           foreach (var key in orderModel.ProductQuantities.Keys) {
    51             var product = (from p in billing.GetProducts() where p.Id == key select p).FirstOrDefault();
    52             orderModel.Products[key] = product;           
    53           }
    54           return View(orderModel);
    55         }
     43    public ActionResult SaveOrder() {
     44      var orderModel = Session["order"] as OrderModel;
     45      foreach (var key in orderModel.ProductQuantities.Keys) {
     46        var product = (from p in billing.GetProducts() where p.ProductId == key select p).FirstOrDefault();
     47        orderModel.Products[key] = product;
     48      }
     49      return View(orderModel);
     50    }
    5651
    57         [HttpPost]
    58         [ActionName("SaveOrder")]
    59         public ActionResult SaveOrderPost() {
    60           var orderModel = Session["order"] as OrderModel;
    61           //TODO: Save order via back-end
    62           var order = new Order() {
    63             State = OrderState.Created,
    64             User = new User() { Name = Membership.GetUser().UserName },
    65             BillingType = orderModel.BillingType,
    66             BillingPeriod = orderModel.BillingPeriod
    67           };
    68          
    69           var orderLines = new List<OrderLine>();
    70           var products = billing.GetProducts();
    71           foreach (var key in orderModel.ProductQuantities.Keys) {
    72             var product = (from p in products where p.Id == key select p).FirstOrDefault();
    73             orderLines.Add(new OrderLine() {
    74                Order = order,
    75                Product = product,
    76                ProductPrice = product.Price,
    77                Quantity = orderModel.ProductQuantities[key]
    78             });
    79           }
    80           order.OrderLines = orderLines;
    81           billing.SaveOrder(order);
    82           return RedirectToAction("OrderSaved");
    83         }
     52    [HttpPost]
     53    [ActionName("SaveOrder")]
     54    public ActionResult SaveOrderPost() {
     55      var orderModel = Session["order"] as OrderModel;
     56      //TODO: Save order via back-end
     57      var order = new Order() {
     58        State = OrderState.Created,
     59        User = new User() { Name = Membership.GetUser().UserName },
     60        BillingType = orderModel.BillingType,
     61        BillingPeriod = orderModel.BillingPeriod
     62      };
    8463
    85         public ActionResult OrderSaved() {
    86           return View();
    87         }
     64      var orderLines = new List<OrderLine>();
     65      var products = billing.GetProducts();
     66      foreach (var key in orderModel.ProductQuantities.Keys) {
     67        var product = (from p in products where p.ProductId == key select p).FirstOrDefault();
     68        orderLines.Add(new OrderLine() {
     69          Order = order,
     70          Product = product,
     71          ProductPrice = product.Price,
     72          Quantity = orderModel.ProductQuantities[key]
     73        });
     74      }
     75      order.OrderLines = orderLines;
     76      billing.SaveOrder(order);
     77      return RedirectToAction("OrderSaved");
    8878    }
     79
     80    public ActionResult OrderSaved() {
     81      return View();
     82    }
     83  }
    8984}
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/WebRole.cs

    r9166 r9576  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using Microsoft.WindowsAzure;
    52using Microsoft.WindowsAzure.Diagnostics;
    63using Microsoft.WindowsAzure.ServiceRuntime;
     
    2320        }
    2421      }
    25       catch (RoleEnvironmentException ex) {
     22      catch (RoleEnvironmentException) {
    2623        // diagnostics connection string not in configuration
    2724        // -> diagnostics disabled
  • branches/OaaS/packages/repositories.config

    r9508 r9576  
    33  <repository path="..\HeuristicLab.Services.Hive.Scaler\packages.config" />
    44  <repository path="..\HeuristicLab.Services.Hive.WebRole\packages.config" />
     5  <repository path="..\HeuristicLab.Services.Optimization.Billing\packages.config" />
    56  <repository path="..\HeuristicLab.Services.Optimization.Controller\packages.config" />
    67  <repository path="..\HeuristicLab.Services.Optimization.Web\packages.config" />
Note: See TracChangeset for help on using the changeset viewer.