Esempio n. 1
0
        public ReturnResult AddContributor(int id, int origin)
        {
            var c = CurrentDatabase.Contributions.SingleOrDefault(cc => cc.ContributionId == id);

            if (c != null)
            {
                var p = PendingList[0];
                AddPerson(p, PendingList, origin, EntryPointId);

                var pushpayev = CurrentDatabase.PeopleExtras.SingleOrDefault(ev => ev.PeopleId == c.PeopleId && ev.Field == "PushPayKey");
                if (pushpayev != null && (c.PeopleId != p.PeopleId))
                {
                    // move the pushpay key with the contribution
                    CurrentDatabase.AddExtraValueDataIfNotExist(p.PeopleId, "PushPayKey", null, null, pushpayev.Data, null, null);
                    CurrentDatabase.PeopleExtras.DeleteOnSubmit(pushpayev);
                }
                c.PeopleId = p.PeopleId;

                if (c.BankAccount.HasValue())
                {
                    var ci = CurrentDatabase.CardIdentifiers.SingleOrDefault(k => k.Id == c.BankAccount);
                    if (ci == null)
                    {
                        ci = new CardIdentifier
                        {
                            Id        = c.BankAccount,
                            CreatedOn = Util.Now
                        };
                        CurrentDatabase.CardIdentifiers.InsertOnSubmit(ci);
                    }
                    ci.PeopleId = p.PeopleId;
                }
                CurrentDatabase.SubmitChanges();
                DbUtil.LogActivity("AddContributor " + c.ContributionId, peopleid: p.PeopleId);
                return(new ReturnResult {
                    close = true, how = "addselected", cid = id, pid = p.PeopleId, name = p.Person.Name2, from = AddContext
                });
            }
            return(new ReturnResult {
                close = true, how = "addselected", from = AddContext
            });
        }