- Timestamp:
- 06/24/13 14:11:05 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OrderController.cs
r9586 r9654 6 6 using HeuristicLab.Services.Optimization.Billing.Interfaces; 7 7 using HeuristicLab.Services.Optimization.Billing.Model; 8 using HeuristicLab.Services.Optimization.Web.Helpers; 8 9 using HeuristicLab.Services.Optimization.Web.Models; 9 using HeuristicLab.Services.Optimization.Web.Helpers;10 10 11 11 namespace HeuristicLab.Services.Optimization.Web.Controllers { … … 18 18 // GET: /Order/ 19 19 20 public ActionResult Index() 21 { 22 if (RedirectToLoginIfNecessary("Order", false)) 23 return View(); 24 return CreateOrder(new OrderModel()); //View(); 25 } 20 public ActionResult Index() { 21 if (RedirectToLoginIfNecessary("Order", false)) 22 return View(); 23 return CreateOrder(new OrderModel()); //View(); 24 } 26 25 27 28 29 30 31 32 33 26 public ActionResult Overview() { 27 if (RedirectToLoginIfNecessary("Order", false)) 28 return View(); 29 MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */); 30 var orders = billing.GetOrders(currentUser.UserName); 31 return View(new OverviewModel() { Orders = orders }); 32 } 34 33 35 34 36 37 38 39 40 41 42 43 44 45 46 47 35 [HttpPost] 36 public ActionResult CreateOrder(OrderModel model) { 37 if (RedirectToLoginIfNecessary("Order", false)) 38 return View(); 39 Session["order"] = model; 40 var currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */); 41 if (billing.GetUser(currentUser.UserName) == null) { 42 billing.SaveUser(new User() { Name = currentUser.UserName, PaymentInformation = new List<PaymentInformation>() }); 43 } 44 model.User = billing.GetUser(currentUser.UserName); 45 return AddProduct(); 46 } 48 47 49 48 public ActionResult AddProduct() { … … 73 72 [ActionName("SaveOrder")] 74 73 public ActionResult SaveOrderPost(OrderModel orderModel) { 74 var user = billing.GetUser(UserName); 75 75 var orderProductModel = Session["order"] as OrderModel; 76 76 //TODO: Save order via back-end 77 77 var order = new Order() { 78 78 State = OrderState.Created, 79 User = new User() { Name = Membership.GetUser().UserName },79 User = user, 80 80 BillingType = orderModel.BillingType, 81 81 BillingPeriod = orderModel.BillingPeriod … … 110 110 oldInfo.AdditionalInformation = model.AdditionalInformation; 111 111 oldInfo.PaymentMethod = model.Method; 112 billing.SaveUser(user); 113 } 114 else { 112 oldInfo.EntityState = State.Modified; 113 } else { 115 114 user.PaymentInformation.Add(new PaymentInformation() { CardNumber = model.CardNumber, AdditionalInformation = model.AdditionalInformation, PaymentMethod = model.Method }); 115 user.EntityState = State.Modified; 116 116 } 117 117 118 billing.SaveUser(user); 118 119 return RedirectToAction("SaveOrder"); 119 120 } … … 122 123 return View(); 123 124 } 125 126 public ActionResult ContactInformation() { 127 var user = billing.GetUser(UserName); 128 var userCi = user.ContactInformation; 129 ContactInformationModel contactInformationModel = null; 130 131 if (userCi == null) { 132 contactInformationModel = new ContactInformationModel(); 133 } else { 134 contactInformationModel = new ContactInformationModel() { 135 ContactInformationId = userCi.ContactInformationId, 136 FirstName = userCi.FirstName, 137 LastName = userCi.LastName, 138 Email = userCi.Email, 139 OrganizationName = userCi.OrganizationName, 140 Street = userCi.Street, 141 PostalCode = userCi.PostalCode, 142 City = userCi.City, 143 State = userCi.State 144 }; 145 } 146 return View(contactInformationModel); 147 } 148 149 [HttpPost] 150 public ActionResult SaveContactInformation(ContactInformationModel model) { 151 var user = billing.GetUser(UserName); 152 var userCi = user.ContactInformation; 153 if (userCi != null) { 154 userCi.City = model.City; 155 userCi.Email = model.Email; 156 userCi.FirstName = model.FirstName; 157 userCi.LastName = model.LastName; 158 userCi.OrganizationName = model.OrganizationName; 159 userCi.PostalCode = model.PostalCode; 160 userCi.State = model.State; 161 userCi.Street = model.Street; 162 userCi.EntityState = State.Modified; 163 } else { 164 user.ContactInformation = new ContactInformation() { 165 City = model.City, 166 Email = model.Email, 167 FirstName = model.FirstName, 168 LastName = model.LastName, 169 OrganizationName = model.OrganizationName, 170 PostalCode = model.PostalCode, 171 State = model.State, 172 Street = model.Street 173 }; 174 user.EntityState = State.Modified; 175 } 176 177 billing.SaveUser(user); 178 179 return RedirectToAction("SaveOrder"); 180 } 124 181 } 125 182 }
Note: See TracChangeset
for help on using the changeset viewer.