Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 15802 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
RevLine 
[9576]1using System.Linq;
[9556]2using System.Web.Mvc;
[9576]3using HeuristicLab.Services.Optimization.Billing.Business;
4using HeuristicLab.Services.Optimization.Billing.Interfaces;
[9556]5using HeuristicLab.Services.Optimization.Web.Models;
[9586]6using HeuristicLab.Services.Optimization.Web.Helpers;
[9556]7
[9576]8namespace HeuristicLab.Services.Optimization.Web.Controllers {
9  [Authorize(Roles = "Web User")]
[9586]10  [BillingFilterActionAttribute]
[9576]11  public class OrderAdminController : Controller {
12    private IOptimizationBilling billing = BillingServiceProvider.Instance;
[9556]13
[9576]14    //
15    // GET: /OrderAdmin/
[9556]16
[9576]17    public ActionResult Index() {
[9582]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      });
[9576]23    }
[9556]24
[9576]25    [HttpPost]
26    public ActionResult ActivateOrder(OrderAdminModel model) {
[9582]27      var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.OrderId == model.OrderId select o).FirstOrDefault();     
[9576]28      order.State = Billing.Model.OrderState.Active;
29      // TODO: Probably activate order via different method
30      billing.SaveOrder(order);
31      return RedirectToAction("Index");
32    }
[9556]33
[9582]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
[9576]52  }
[9556]53}
Note: See TracBrowser for help on using the repository browser.