Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9558 was 9558, checked in by fschoepp, 11 years ago

#1888:

  • Added Usage statistic classes; added authorization attributes to web controllers.
File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.Mvc;
6using HeuristicLab.Services.Optimization.Web.Models;
7using HeuristicLab.Services.Optimization.Billing.Interfaces;
8using HeuristicLab.Services.Optimization.Billing;
9
10namespace HeuristicLab.Services.Optimization.Web.Controllers
11{
12    [Authorize(Roles = "Web User")]
13    public class OrderAdminController : Controller
14    {
15        private IOptimizationBilling billing = new MockupOptimizationBilling();
16
17        //
18        // GET: /OrderAdmin/
19
20        public ActionResult Index()
21        {
22            var orders = billing.GetOrdersByState(Billing.Model.OrderState.Created);
23            return View(new OrderAdminModel() { Orders = orders });
24        }
25
26        [HttpPost]
27        public ActionResult ActivateOrder(OrderAdminModel model) {
28          var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.Id == model.OrderId select o).FirstOrDefault();
29          order.State = Billing.Model.OrderState.Active;
30          // TODO: Probably activate order via different method
31          billing.SaveOrder(order);
32          return RedirectToAction("Index");
33        }
34
35    }
36}
Note: See TracBrowser for help on using the repository browser.