コード例 #1
0
ファイル: ManageGiving.cs プロジェクト: rastographics/bvcms
        public ActionResult ManageGiving(ManageGivingModel m)
        {
            m.SetCurrentDatabase(CurrentDatabase);
            SetHeaders(m.orgid);

            // only validate if the amounts are greater than zero.
            if (m.FundItemsChosen().Sum(f => f.amt) > 0)
            {
                m.ValidateModel(ModelState);
                if (!ModelState.IsValid)
                {
                    if (m.person == null)
                    {
                        return(Message("person not found"));
                    }
                    m.total = 0;
                    foreach (var ff in m.FundItemsChosen())
                    {
                        m.total += ff.amt;
                    }
                    return(View("ManageGiving/Setup", m));
                }
            }
            else
            {
                ModelState.AddModelError("funds", "You must choose at least one fund to give to.");
                return(View("ManageGiving/Setup", m));
            }
            if (CurrentDatabase.Setting("UseRecaptchaForManageGiving"))
            {
                if (!GoogleRecaptcha.IsValidResponse(HttpContext, CurrentDatabase))
                {
                    ModelState.AddModelError("TranId", "ReCaptcha validation failed.");
                    return(View("ManageGiving/Setup", m));
                }
            }

            try
            {
                m.Update();
            }
            catch (Exception ex)
            {
                if (ex.Message == "InvalidVaultId")
                {
                    m = ClearPaymentInfo(m, ModelState);
                }
                else
                {
                    ModelState.AddModelError("form", ex.Message);
                }
            }
            if (!ModelState.IsValid)
            {
                return(View("ManageGiving/Setup", m));
            }

            RequestManager.SessionProvider.Add("managegiving", m);
            return(Redirect("/OnlineReg/ConfirmRecurringGiving"));
        }
コード例 #2
0
        public ActionResult ManageGiving(ManageGivingModel m)
        {
            SetHeaders(m.orgid);

            // only validate if the amounts are greater than zero.
            if (m.FundItemsChosen().Sum(f => f.amt) > 0)
            {
                m.ValidateModel(ModelState);
                if (!ModelState.IsValid)
                {
                    m.total = 0;
                    foreach (var ff in m.FundItemsChosen())
                    {
                        m.total += ff.amt;
                    }
                    return(View("ManageGiving/Setup", m));
                }
            }

            try
            {
                m.Update();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("form", ex.Message);
            }
            if (!ModelState.IsValid)
            {
                return(View("ManageGiving/Setup", m));
            }

            TempData["managegiving"] = m;
            return(Redirect("/OnlineReg/ConfirmRecurringGiving"));
        }
コード例 #3
0
        public ActionResult ManageGiving2(int id)
        {
            var model = new ManageGivingModel(CurrentDatabase.Host, id);

            model.testing = true; // TODO: Is this really necessary?
            return(View(model));
        }
コード例 #4
0
ファイル: ManageGiving.cs プロジェクト: chrisgundersen/bvcms
		public ActionResult ManageGiving(string id, bool? testing)
		{
			if (!id.HasValue())
				return Content("bad link");
			ManageGivingModel m = null;
			var td = TempData["mg"];
			if (td != null)
				m = new ManageGivingModel(td.ToInt(), id.ToInt());
			else
			{
				var guid = id.ToGuid();
				if (guid == null)
					return Content("invalid link");
				var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
				if (ot == null)
					return Content("invalid link");
#if DEBUG2
#else
				if (ot.Used)
					return Content("link used");
#endif
				if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
					return Content("link expired");
				var a = ot.Querystring.Split(',');
				m = new ManageGivingModel(a[1].ToInt(), a[0].ToInt());
				ot.Used = true;
				DbUtil.Db.SubmitChanges();
			}
			if (!m.testing)
				m.testing = testing ?? false;
			SetHeaders(m.orgid);
			DbUtil.LogActivity("Manage Giving: {0} ({1})".Fmt(m.Organization.OrganizationName, m.person.Name));
            return View("ManageGiving/Setup", m);
		}
コード例 #5
0
ファイル: ManageGiving.cs プロジェクト: bsbillings/bvcms
        public ActionResult ManageGiving(string id, bool?testing)
        {
            if (!id.HasValue())
            {
                return(Message("bad link"));
            }
            ManageGivingModel m = null;
            var td = TempData["PeopleId"];

            if (td != null)
            {
                m = new ManageGivingModel(td.ToInt(), id.ToInt());
                if (m.person == null)
                {
                    return(Message("person not found"));
                }
            }
            else
            {
                var guid = id.ToGuid();
                if (guid == null)
                {
                    return(Content("invalid link"));
                }
                var ot = CurrentDatabase.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                if (ot == null)
                {
                    return(Content("invalid link"));
                }
#if DEBUG2
#else
                if (ot.Used)
                {
                    return(Content("link used"));
                }
#endif
                if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                {
                    return(Content("link expired"));
                }
                var a = ot.Querystring.Split(',');
                m = new ManageGivingModel(a[1].ToInt(), a[0].ToInt());
                if (m.person == null)
                {
                    return(Message("person not found"));
                }
                ot.Used = true;
                CurrentDatabase.SubmitChanges();
            }
            Session["CreditCardOnFile"] = m.CreditCard;
            Session["ExpiresOnFile"]    = m.Expires;
            if (!m.testing)
            {
                m.testing = testing ?? false;
            }
            SetHeaders(m.orgid);
            m.Log("Start");
            return(View("ManageGiving/Setup", m));
        }
コード例 #6
0
        public ActionResult DeleteVaultData(int id)
        {
            var manageGiving = new ManageGivingModel();

            manageGiving.CancelManagedGiving(id);

            return(Content("ok"));
        }
コード例 #7
0
        public ActionResult ManageGiving2(int id)
        {
            var m = new ManageGivingModel(id);

            m.testing = true;
            var body = ViewExtensions2.RenderPartialViewToString(this, "ManageGiving2", m);

            return(Content(body));
        }
コード例 #8
0
ファイル: ManageGiving.cs プロジェクト: bsbillings/bvcms
        public ActionResult RemoveManagedGiving(int peopleId, int orgId)
        {
            var m = new ManageGivingModel(peopleId, orgId);

            m.CancelManagedGiving(peopleId);
            m.ThankYouMessage = "Your recurring giving has been stopped.";

            m.Log("Remove");
            TempData["managegiving"] = m;
            return(Json(new { Url = Url.Action("ConfirmRecurringGiving") }));
        }
コード例 #9
0
ファイル: ManageGiving.cs プロジェクト: rastographics/bvcms
        public ActionResult RemoveManagedGiving(int peopleId, int orgId)
        {
            var m = new ManageGivingModel(CurrentDatabase.Host, peopleId, orgId);

            m.CancelManagedGiving(peopleId);
            m.ThankYouMessage = "Your recurring giving has been stopped.";

            m.Log("Remove");
            RequestManager.SessionProvider.Add("managegiving", m);
            return(Json(new { Url = Url.Action("ConfirmRecurringGiving") }));
        }
コード例 #10
0
ファイル: ManageGiving.cs プロジェクト: rastographics/bvcms
 private ManageGivingModel ClearPaymentInfo(ManageGivingModel m, ModelStateDictionary modelState)
 {
     m.CreditCard = string.Empty;
     m.Expires    = string.Empty;
     m.Routing    = string.Empty;
     m.Account    = string.Empty;
     m.CVV        = string.Empty;
     modelState.Clear();
     modelState.AddModelError("form", "Please insert your payment information.");
     return(m);
 }
コード例 #11
0
ファイル: ManageGiving.cs プロジェクト: pwgoertz/bvcms
        public ActionResult ManageGiving(ManageGivingModel m)
        {
            SetHeaders(m.orgid);

            // only validate if the amounts are greater than zero.
            if (m.FundItemsChosen().Sum(f => f.amt) > 0)
            {
                m.ValidateModel(ModelState);
                if (!ModelState.IsValid)
                {
                    if (m.person == null)
                    {
                        return(Message("person not found"));
                    }
                    m.total = 0;
                    foreach (var ff in m.FundItemsChosen())
                    {
                        m.total += ff.amt;
                    }
                    return(View("ManageGiving/Setup", m));
                }
            }
            if (CurrentDatabase.Setting("UseRecaptchaForManageGiving"))
            {
                if (!GoogleRecaptcha.IsValidResponse(HttpContext, CurrentDatabase))
                {
                    ModelState.AddModelError("TranId", "ReCaptcha validation failed.");
                    return(View("ManageGiving/Setup", m));
                }
            }

            try
            {
                m.Update();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("form", ex.Message);
            }
            if (!ModelState.IsValid)
            {
                return(View("ManageGiving/Setup", m));
            }

            TempData["managegiving"] = m;
            return(Redirect("/OnlineReg/ConfirmRecurringGiving"));
        }
コード例 #12
0
ファイル: ManageGiving.cs プロジェクト: chrisgundersen/bvcms
		public ActionResult ManageGiving(ManageGivingModel m)
		{
			SetHeaders(m.orgid);
			m.ValidateModel(ModelState);
			if (!ModelState.IsValid)
				return View("ManageGiving/Setup", m);
			try
			{
				m.Update();
			}
			catch (Exception ex)
			{
				ModelState.AddModelError("form", ex.Message);
			}
			if (!ModelState.IsValid)
				return View("ManageGiving/Setup", m);
			TempData["managegiving"] = m;
			return Redirect("/OnlineReg/ConfirmRecurringGiving");
		}
コード例 #13
0
        private static void RemoveNonDigitsIfNecessary(ManageGivingModel m)
        {
            bool dorouting = false;
            bool doaccount = m.Account.HasValue() && !m.Account.StartsWith("X");

            if (m.Routing.HasValue() && !m.Routing.StartsWith("X"))
            {
                dorouting = true;
            }

            if (doaccount || dorouting)
            {
                if (doaccount)
                {
                    m.Account = m.Account.GetDigits();
                }
                if (dorouting)
                {
                    m.Routing = m.Routing.GetDigits();
                }
            }
        }
コード例 #14
0
 public ActionResult ManageGiving2(int id)
 {
     var m = new ManageGivingModel(id);
     m.testing = true;
     var body = ViewExtensions2.RenderPartialViewToString(this, "ManageGiving2", m);
     return Content(body);
 }
コード例 #15
0
        public ActionResult ManageGiving(ManageGivingModel m)
        {
            SetHeaders(m.orgid);
            RemoveNonDigitsIfNecessary(m);
            m.ValidateModel(ModelState);
            if (!ModelState.IsValid)
            {
                return(View(m));
            }
            try
            {
                var gateway = OnlineRegModel.GetTransactionGateway();
                if (gateway == "authorizenet")
                {
                    var au = new AuthorizeNet(DbUtil.Db, m.testing);
                    au.AddUpdateCustomerProfile(m.pid,
                                                m.Type,
                                                m.Cardnumber,
                                                m.Expires,
                                                m.Cardcode,
                                                m.Routing,
                                                m.Account);
                }
                else if (gateway == "sage")
                {
                    var sg = new SagePayments(DbUtil.Db, m.testing);
                    sg.storeVault(m.pid,
                                  m.Type,
                                  m.Cardnumber,
                                  m.Expires,
                                  m.Cardcode,
                                  m.Routing,
                                  m.Account,
                                  giving: true);
                }
                else
                {
                    throw new Exception("ServiceU not supported");
                }

                var mg = m.person.ManagedGiving();
                if (mg == null)
                {
                    mg = new ManagedGiving();
                    m.person.ManagedGivings.Add(mg);
                }
                mg.SemiEvery = m.SemiEvery;
                mg.Day1      = m.Day1;
                mg.Day2      = m.Day2;
                mg.EveryN    = m.EveryN;
                mg.Period    = m.Period;
                mg.StartWhen = m.StartWhen;
                mg.StopWhen  = m.StopWhen;
                mg.NextDate  = mg.FindNextDate(DateTime.Today);

                var pi = m.person.PaymentInfo();
                pi.FirstName     = m.firstname.Truncate(50);
                pi.MiddleInitial = m.middleinitial.Truncate(10);
                pi.LastName      = m.lastname.Truncate(50);
                pi.Suffix        = m.suffix.Truncate(10);
                pi.Address       = m.address.Truncate(50);
                pi.City          = m.city.Truncate(50);
                pi.State         = m.state.Truncate(10);
                pi.Zip           = m.zip.Truncate(15);
                pi.Phone         = m.phone.Truncate(25);

                var q = from ra in DbUtil.Db.RecurringAmounts
                        where ra.PeopleId == m.pid
                        select ra;
                DbUtil.Db.RecurringAmounts.DeleteAllOnSubmit(q);
                DbUtil.Db.SubmitChanges();
                foreach (var c in m.FundItemsChosen())
                {
                    var ra = new RecurringAmount
                    {
                        PeopleId = m.pid,
                        FundId   = c.fundid,
                        Amt      = c.amt
                    };
                    DbUtil.Db.RecurringAmounts.InsertOnSubmit(ra);
                }
                DbUtil.Db.SubmitChanges();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("form", ex.Message);
            }
            if (!ModelState.IsValid)
            {
                return(View(m));
            }
            TempData["managegiving"] = m;
            return(Redirect("ConfirmRecurringGiving"));
        }