예제 #1
0
파일: ManageGiving.cs 프로젝트: vs06/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");
 }
예제 #2
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");
        }