public virtual ActionResult Confirm(OrderConfirmViewModel model) { var orderUtils = new OrderUtils(_context, CurrentUserId); if (!model.OrderConfirmed) { // Regenerate the model model = orderUtils.GetConfirmModel(model.ProductId); ModelState.AddModelError("OrderConfirmed", "You must check the confirmation box to activate this license"); return View(model); } var createdOrder = orderUtils.CreateOrder(model.ProductId); if (createdOrder.OrderStatus == OrderStatus.AwaitingPayment) return RedirectToAction(MVC.Products.Pay.Index(createdOrder.Id)); else if (createdOrder.OrderStatus != OrderStatus.Completed) throw new InvalidOperationException( string.Format("Order status of {0} is not supported", createdOrder.OrderStatus.ToString())); // Order was completed as it was free orderUtils.ActivateOrderedLicenses(createdOrder); string LicenseType = orderUtils.GetLicenseDescription(createdOrder.FillPerfectLicenses.First().LicenseType); return RedirectToAction( MVC.Products.FillPerfect.LicenseActivated( (Guid)_context.Users.Find(createdOrder.OrderedForId).FillPerfectKey, createdOrder.FillPerfectLicenses.First().EffectiveDate, createdOrder.FillPerfectLicenses.First().ExpirationDate, LicenseType)); }
public virtual ActionResult Confirm(int productId) { var orderUtils = new OrderUtils(_context, CurrentUserId); var model = orderUtils.GetConfirmModel(productId); if (model == null) throw new InvalidOperationException( string.Format("Product id {0} was not found", productId)); // Set the effective date to today if the last license expired prior to today if (model.LicenseEffectiveDate <= DateTime.Today) model.LicenseEffectiveDate = DateTime.Today; return View(model); }
public virtual ActionResult Confirm(int productId) { var orderUtils = new OrderUtils(_context, CurrentUserId); var model = orderUtils.GetConfirmModel(productId); if (model == null) { throw new InvalidOperationException( string.Format("Product id {0} was not found", productId)); } // Set the effective date to today if the last license expired prior to today if (model.LicenseEffectiveDate <= DateTime.Today) { model.LicenseEffectiveDate = DateTime.Today; } return(View(model)); }
public virtual ActionResult Confirm(OrderConfirmViewModel model) { var orderUtils = new OrderUtils(_context, CurrentUserId); if (!model.OrderConfirmed) { // Regenerate the model model = orderUtils.GetConfirmModel(model.ProductId); ModelState.AddModelError("OrderConfirmed", "You must check the confirmation box to activate this license"); return(View(model)); } var createdOrder = orderUtils.CreateOrder(model.ProductId); if (createdOrder.OrderStatus == OrderStatus.AwaitingPayment) { return(RedirectToAction(MVC.Products.Pay.Index(createdOrder.Id))); } else if (createdOrder.OrderStatus != OrderStatus.Completed) { throw new InvalidOperationException( string.Format("Order status of {0} is not supported", createdOrder.OrderStatus.ToString())); } // Order was completed as it was free orderUtils.ActivateOrderedLicenses(createdOrder); string LicenseType = orderUtils.GetLicenseDescription(createdOrder.FillPerfectLicenses.First().LicenseType); return(RedirectToAction( MVC.Products.FillPerfect.LicenseActivated( (Guid)_context.Users.Find(createdOrder.OrderedForId).FillPerfectKey, createdOrder.FillPerfectLicenses.First().EffectiveDate, createdOrder.FillPerfectLicenses.First().ExpirationDate, LicenseType))); }