using System.Linq; using System.Web.Mvc; using HeuristicLab.Services.Optimization.Billing.Business; using HeuristicLab.Services.Optimization.Billing.Interfaces; using HeuristicLab.Services.Optimization.Web.Models; using HeuristicLab.Services.Optimization.Web.Helpers; namespace HeuristicLab.Services.Optimization.Web.Controllers { [Authorize(Roles = "Web User")] [BillingFilterActionAttribute] public class OrderAdminController : Controller { private IOptimizationBilling billing = BillingServiceProvider.Instance; // // GET: /OrderAdmin/ public ActionResult Index() { return View(new OrderAdminModel() { ActiveOrders = billing.GetOrdersByState(Billing.Model.OrderState.Active), CreatedOrders = billing.GetOrdersByState(Billing.Model.OrderState.Created), SuspendedOrders = billing.GetOrdersByState(Billing.Model.OrderState.Suspended) }); } [HttpPost] public ActionResult ActivateOrder(OrderAdminModel model) { var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.OrderId == model.OrderId select o).FirstOrDefault(); order.State = Billing.Model.OrderState.Active; // TODO: Probably activate order via different method billing.SaveOrder(order); return RedirectToAction("Index"); } [HttpPost] public ActionResult SuspendOrder(OrderAdminModel model) { var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Active) where o.OrderId == model.OrderId select o).FirstOrDefault(); order.State = Billing.Model.OrderState.Suspended; // TODO: Probably activate order via different method billing.SaveOrder(order); return RedirectToAction("Index"); } [HttpPost] public ActionResult ReactivateOrder(OrderAdminModel model) { var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Suspended) where o.OrderId == model.OrderId select o).FirstOrDefault(); order.State = Billing.Model.OrderState.Active; // TODO: Probably activate order via different method billing.SaveOrder(order); return RedirectToAction("Index"); } } }