Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OrderAdminController.cs @ 15557

Last change on this file since 15557 was 9586, checked in by fschoepp, 12 years ago

#1888:

  • Billing Component may now be deactivated by setting the BillingEnabled flag within the OaaS service configuration.
  • Added views for invoices and usage data.
  • Changed appearance of the SaveOrder view.
File size: 2.2 KB
Line 
1using System.Linq;
2using System.Web.Mvc;
3using HeuristicLab.Services.Optimization.Billing.Business;
4using HeuristicLab.Services.Optimization.Billing.Interfaces;
5using HeuristicLab.Services.Optimization.Web.Models;
6using HeuristicLab.Services.Optimization.Web.Helpers;
7
8namespace HeuristicLab.Services.Optimization.Web.Controllers {
9  [Authorize(Roles = "Web User")]
10  [BillingFilterActionAttribute]
11  public class OrderAdminController : Controller {
12    private IOptimizationBilling billing = BillingServiceProvider.Instance;
13
14    //
15    // GET: /OrderAdmin/
16
17    public ActionResult Index() {
18      return View(new OrderAdminModel() {
19        ActiveOrders = billing.GetOrdersByState(Billing.Model.OrderState.Active),
20        CreatedOrders = billing.GetOrdersByState(Billing.Model.OrderState.Created),
21        SuspendedOrders = billing.GetOrdersByState(Billing.Model.OrderState.Suspended)
22      });
23    }
24
25    [HttpPost]
26    public ActionResult ActivateOrder(OrderAdminModel model) {
27      var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.OrderId == model.OrderId select o).FirstOrDefault();     
28      order.State = Billing.Model.OrderState.Active;
29      // TODO: Probably activate order via different method
30      billing.SaveOrder(order);
31      return RedirectToAction("Index");
32    }
33
34    [HttpPost]
35    public ActionResult SuspendOrder(OrderAdminModel model) {
36      var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Active) where o.OrderId == model.OrderId select o).FirstOrDefault();
37      order.State = Billing.Model.OrderState.Suspended;
38      // TODO: Probably activate order via different method
39      billing.SaveOrder(order);
40      return RedirectToAction("Index");
41    }
42
43    [HttpPost]
44    public ActionResult ReactivateOrder(OrderAdminModel model) {
45      var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Suspended) where o.OrderId == model.OrderId select o).FirstOrDefault();
46      order.State = Billing.Model.OrderState.Active;
47      // TODO: Probably activate order via different method
48      billing.SaveOrder(order);
49      return RedirectToAction("Index");
50    }
51
52  }
53}
Note: See TracBrowser for help on using the repository browser.