Esempio n. 1
0
        //[Authorize]
        public ActionResult Calculator()
        {
            var testToken = SessionHelper.TestToken;

            // Alaways re-query
            var pumps = new List<TestMembershipPump>();
            var pump = (TestMembershipPump) null;
            if (testToken != null)
                pump = _yesrRepository.RetrieveTestMembershipPumpByToken(testToken);
            if (pump != null)
                pumps.Add(pump);

            // Set default values in the model
            var model = new CalculatorViewModel()
            {
                Token = "",
                Referrals = 10,
                AverageMonthlySpend = 2500,
                Years = 1,
                Pumps = pumps
            };

            return View(model);
        }
Esempio n. 2
0
        public ActionResult Calculator(CalculatorViewModel model)
        {
            if (ModelState.IsValid)
            {
                //Thread started =  _yesrRepository.PumpMemberships(model.Memberships, model.PurchasesPerMembership, model.DaysBetweenPurchases);
                //if (started == null)
                //    ModelState.AddModelError("", "There is already a running pump!!!");
                //else
                //    return RedirectToAction("Index", "Home", new { area = "" });

                // Store in session
                SessionHelper.TestToken = model.Token;
                _yesrRepository.PumpTestMembership(model.Token, model.Referrals, model.AverageMonthlySpend, model.Years, true);
                return RedirectToAction("Calculator", "Home", new { area = "" });
            }
            else
            {
                ModelState.AddModelError("", "Something is wrong!");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }