Beispiel #1
0
        public virtual ActionResult ConfirmFillPerfectOrgOrder(FillPerfectOrgLicenseConfirmViewModel model)
        {
            var orderUtils = new OrderUtils(_context, CurrentUserId);

            if (!model.OrderConfirmed)
            {
                // Regenerate the model
                model = orderUtils.GetFpOrgConfirmModel();
                ModelState.AddModelError("OrderConfirmed", "You must check the confirmation box to activate this license");
                return(View(model));
            }

            // Regenerate the model for license details
            model = orderUtils.GetFpOrgConfirmModel();

            // Create the order and automatically activate the license
            var order = orderUtils.CreateOrder();

            order.FillPerfectLicenses.Add(new FpUserLicense
            {
                LicenseType    = FillPerfectLicenseType.OrganizationGranted,
                EffectiveDate  = model.ActivatedLicenseExpiratioDate >= model.EffectiveLicenseDate ? model.ActivatedLicenseExpiratioDate : model.EffectiveLicenseDate,
                ExpirationDate = model.ExpirationDate
            });

            // Make sure the user has a FP key
            var user = _context.Users.Find(order.OrderedForId);

            if (user.FillPerfectKey == null)
            {
                user.FillPerfectKey = Guid.NewGuid();
            }

            _context.SaveChanges();

            // Show the user confirmation
            string orgName = _context.Users.Where(x => x.Id == CurrentUserId).Select(x => x.Organization.Name).FirstOrDefault();

            return(RedirectToAction(
                       MVC.Products.FillPerfect.LicenseActivated(
                           (Guid)user.FillPerfectKey,
                           order.FillPerfectLicenses.First().EffectiveDate,
                           order.FillPerfectLicenses.First().ExpirationDate,
                           "License granted by " + orgName)));
        }
        public virtual ActionResult ConfirmFillPerfectOrgOrder()
        {
            var orderUtils = new OrderUtils(_context, CurrentUserId);
            var model = orderUtils.GetFpOrgConfirmModel();
            if (model == null)
                throw new InvalidOperationException("Organization does not have a FP license");

            return View(model);
        }
Beispiel #3
0
        public virtual ActionResult ConfirmFillPerfectOrgOrder()
        {
            var orderUtils = new OrderUtils(_context, CurrentUserId);
            var model      = orderUtils.GetFpOrgConfirmModel();

            if (model == null)
            {
                throw new InvalidOperationException("Organization does not have a FP license");
            }

            return(View(model));
        }
        public virtual ActionResult ConfirmFillPerfectOrgOrder(FillPerfectOrgLicenseConfirmViewModel model)
        {
            var orderUtils = new OrderUtils(_context, CurrentUserId);

            if (!model.OrderConfirmed)
            {
                // Regenerate the model
                model = orderUtils.GetFpOrgConfirmModel();
                ModelState.AddModelError("OrderConfirmed", "You must check the confirmation box to activate this license");
                return View(model);
            }

            // Regenerate the model for license details
            model = orderUtils.GetFpOrgConfirmModel();

            // Create the order and automatically activate the license
            var order = orderUtils.CreateOrder();
            order.FillPerfectLicenses.Add(new FpUserLicense
            {
                LicenseType = FillPerfectLicenseType.OrganizationGranted,
                EffectiveDate = model.ActivatedLicenseExpiratioDate >= model.EffectiveLicenseDate ? model.ActivatedLicenseExpiratioDate : model.EffectiveLicenseDate,
                ExpirationDate = model.ExpirationDate
            });

            // Make sure the user has a FP key
            var user = _context.Users.Find(order.OrderedForId);
            if (user.FillPerfectKey == null)
                user.FillPerfectKey = Guid.NewGuid();

            _context.SaveChanges();

            // Show the user confirmation
            string orgName = _context.Users.Where(x => x.Id == CurrentUserId).Select(x => x.Organization.Name).FirstOrDefault();

            return RedirectToAction(
                MVC.Products.FillPerfect.LicenseActivated(
                    (Guid)user.FillPerfectKey,
                    order.FillPerfectLicenses.First().EffectiveDate,
                    order.FillPerfectLicenses.First().ExpirationDate,
                    "License granted by " + orgName));
        }