1 | using System.Linq;
|
---|
2 | using System.Web.Mvc;
|
---|
3 | using HeuristicLab.Services.Optimization.Billing.Business;
|
---|
4 | using HeuristicLab.Services.Optimization.Billing.Interfaces;
|
---|
5 | using HeuristicLab.Services.Optimization.Web.Models;
|
---|
6 | using HeuristicLab.Services.Optimization.Web.Helpers;
|
---|
7 |
|
---|
8 | namespace 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 | }
|
---|