Changeset 9576 for branches/OaaS/HeuristicLab.Services.Optimization.Web
- Timestamp:
- 06/04/13 10:59:03 (11 years ago)
- Location:
- branches/OaaS/HeuristicLab.Services.Optimization.Web
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OrderAdminController.cs
r9558 r9576 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 1 using System.Linq; 5 2 using System.Web.Mvc; 3 using HeuristicLab.Services.Optimization.Billing.Business; 4 using HeuristicLab.Services.Optimization.Billing.Interfaces; 6 5 using HeuristicLab.Services.Optimization.Web.Models; 7 using HeuristicLab.Services.Optimization.Billing.Interfaces;8 using HeuristicLab.Services.Optimization.Billing;9 6 10 namespace HeuristicLab.Services.Optimization.Web.Controllers 11 { 12 [Authorize(Roles = "Web User")] 13 public class OrderAdminController : Controller 14 { 15 private IOptimizationBilling billing = new MockupOptimizationBilling(); 7 namespace HeuristicLab.Services.Optimization.Web.Controllers { 8 [Authorize(Roles = "Web User")] 9 public class OrderAdminController : Controller { 10 private IOptimizationBilling billing = BillingServiceProvider.Instance; 16 11 17 18 12 // 13 // GET: /OrderAdmin/ 19 14 20 public ActionResult Index() 21 { 22 var orders = billing.GetOrdersByState(Billing.Model.OrderState.Created); 23 return View(new OrderAdminModel() { Orders = orders }); 24 } 15 public ActionResult Index() { 16 var orders = billing.GetOrdersByState(Billing.Model.OrderState.Created); 17 return View(new OrderAdminModel() { Orders = orders }); 18 } 25 19 26 27 28 var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.Id == model.OrderId select o).FirstOrDefault();29 30 31 32 33 20 [HttpPost] 21 public ActionResult ActivateOrder(OrderAdminModel model) { 22 var order = (from o in billing.GetOrdersByState(Billing.Model.OrderState.Created) where o.OrderId == model.OrderId select o).FirstOrDefault(); 23 order.State = Billing.Model.OrderState.Active; 24 // TODO: Probably activate order via different method 25 billing.SaveOrder(order); 26 return RedirectToAction("Index"); 27 } 34 28 35 29 } 36 30 } -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OrderController.cs
r9558 r9576 1 using System; 2 using System.Collections.Generic; 1 using System.Collections.Generic; 3 2 using System.Linq; 4 using System.Web;5 3 using System.Web.Mvc; 4 using System.Web.Security; 5 using HeuristicLab.Services.Optimization.Billing.Business; 6 using HeuristicLab.Services.Optimization.Billing.Interfaces; 7 using HeuristicLab.Services.Optimization.Billing.Model; 6 8 using HeuristicLab.Services.Optimization.Web.Models; 7 using HeuristicLab.Services.Optimization.Billing.Model;8 using HeuristicLab.Services.Optimization.Billing.Interfaces;9 using HeuristicLab.Services.Optimization.Billing;10 using System.Web.Security;11 9 12 namespace HeuristicLab.Services.Optimization.Web.Controllers 13 { 14 [Authorize(Roles = "Web User")] 15 public class OrderController : Controller 16 { 17 private IOptimizationBilling billing = new MockupOptimizationBilling(); 10 namespace HeuristicLab.Services.Optimization.Web.Controllers { 11 [Authorize(Roles = "Web User")] 12 public class OrderController : Controller { 13 private IOptimizationBilling billing = BillingServiceProvider.Instance; 18 14 19 20 15 // 16 // GET: /Order/ 21 17 22 public ActionResult Index() 23 { 24 return CreateOrder(new OrderModel()); //View(); 25 } 18 public ActionResult Index() { 19 return CreateOrder(new OrderModel()); //View(); 20 } 26 21 27 22 28 29 30 31 32 23 [HttpPost] 24 public ActionResult CreateOrder(OrderModel model) { 25 Session["order"] = model; 26 return AddProduct(); 27 } 33 28 34 35 36 29 public ActionResult AddProduct() { 30 return View("AddProduct", new ProductsModel() { Products = billing.GetProducts() }); 31 } 37 32 38 39 40 41 var prod = (from b in billing.GetProducts()42 where b.Id == product.ProductId43 44 order.ProductQuantities[prod.Id] = product.Quantity;45 46 33 [HttpPost] 34 public ActionResult AddProduct(ProductsModel product) { 35 var order = Session["order"] as OrderModel; 36 var prod = (from b in billing.GetProducts() 37 where b.ProductId == product.ProductId 38 select b).FirstOrDefault(); 39 order.ProductQuantities[prod.ProductId] = product.Quantity; 40 return AddProduct(); 41 } 47 42 48 49 50 51 var product = (from p in billing.GetProducts() where p.Id == key select p).FirstOrDefault();52 orderModel.Products[key] = product;53 54 55 43 public ActionResult SaveOrder() { 44 var orderModel = Session["order"] as OrderModel; 45 foreach (var key in orderModel.ProductQuantities.Keys) { 46 var product = (from p in billing.GetProducts() where p.ProductId == key select p).FirstOrDefault(); 47 orderModel.Products[key] = product; 48 } 49 return View(orderModel); 50 } 56 51 57 [HttpPost] 58 [ActionName("SaveOrder")] 59 public ActionResult SaveOrderPost() { 60 var orderModel = Session["order"] as OrderModel; 61 //TODO: Save order via back-end 62 var order = new Order() { 63 State = OrderState.Created, 64 User = new User() { Name = Membership.GetUser().UserName }, 65 BillingType = orderModel.BillingType, 66 BillingPeriod = orderModel.BillingPeriod 67 }; 68 69 var orderLines = new List<OrderLine>(); 70 var products = billing.GetProducts(); 71 foreach (var key in orderModel.ProductQuantities.Keys) { 72 var product = (from p in products where p.Id == key select p).FirstOrDefault(); 73 orderLines.Add(new OrderLine() { 74 Order = order, 75 Product = product, 76 ProductPrice = product.Price, 77 Quantity = orderModel.ProductQuantities[key] 78 }); 79 } 80 order.OrderLines = orderLines; 81 billing.SaveOrder(order); 82 return RedirectToAction("OrderSaved"); 83 } 52 [HttpPost] 53 [ActionName("SaveOrder")] 54 public ActionResult SaveOrderPost() { 55 var orderModel = Session["order"] as OrderModel; 56 //TODO: Save order via back-end 57 var order = new Order() { 58 State = OrderState.Created, 59 User = new User() { Name = Membership.GetUser().UserName }, 60 BillingType = orderModel.BillingType, 61 BillingPeriod = orderModel.BillingPeriod 62 }; 84 63 85 public ActionResult OrderSaved() { 86 return View(); 87 } 64 var orderLines = new List<OrderLine>(); 65 var products = billing.GetProducts(); 66 foreach (var key in orderModel.ProductQuantities.Keys) { 67 var product = (from p in products where p.ProductId == key select p).FirstOrDefault(); 68 orderLines.Add(new OrderLine() { 69 Order = order, 70 Product = product, 71 ProductPrice = product.Price, 72 Quantity = orderModel.ProductQuantities[key] 73 }); 74 } 75 order.OrderLines = orderLines; 76 billing.SaveOrder(order); 77 return RedirectToAction("OrderSaved"); 88 78 } 79 80 public ActionResult OrderSaved() { 81 return View(); 82 } 83 } 89 84 } -
branches/OaaS/HeuristicLab.Services.Optimization.Web/WebRole.cs
r9166 r9576 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using Microsoft.WindowsAzure;5 2 using Microsoft.WindowsAzure.Diagnostics; 6 3 using Microsoft.WindowsAzure.ServiceRuntime; … … 23 20 } 24 21 } 25 catch (RoleEnvironmentException ex) {22 catch (RoleEnvironmentException) { 26 23 // diagnostics connection string not in configuration 27 24 // -> diagnostics disabled
Note: See TracChangeset
for help on using the changeset viewer.