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