public ContentResult AddIDCard(string cardid, int personid, bool overwrite = false)
        {
            var error = ADD_ERROR_NONE;

            var card = (from e in DbUtil.Db.CardIdentifiers
                        where e.Id == cardid
                        select e).FirstOrDefault();

            if (card == null)
            {
                var ci = new CardIdentifier();
                ci.Id = cardid;
                ci.PeopleId = personid;

                DbUtil.Db.CardIdentifiers.InsertOnSubmit(ci);
                DbUtil.Db.SubmitChanges();
            }
            else if (overwrite)
            {
                card.PeopleId = personid;
                DbUtil.Db.SubmitChanges();
            }
            else
            {
                error = ADD_ERROR_EXISTS;
            }

            return Content(error.ToString());
            // Error return: 0 = None, 1 = Exists, 2 = Other
        }
 public ContentResult NewKeyCard(int pid, string KeyCode)
 {
     if (!Authenticate())
         return Content("not authorized");
     var p = DbUtil.Db.LoadPersonById(pid);
     if (p == null)
         return Content("No person to associate card with");
     var q = from kc in DbUtil.Db.CardIdentifiers
             where KeyCode == kc.Id
             select kc;
     var card = q.SingleOrDefault();
     if (card == null)
     {
         card = new CardIdentifier {Id = KeyCode};
         DbUtil.Db.CardIdentifiers.InsertOnSubmit(card);
     }
     card.PeopleId = pid;
     DbUtil.Db.SubmitChanges();
     return Content("Card Associated");
 }
Example #3
0
        private ReturnResult AddContributor(int id, int origin)
        {
            var c = DbUtil.Db.Contributions.SingleOrDefault(cc => cc.ContributionId == id);
            if (c != null)
            {
                var p = PendingList[0];
                AddPerson(p, PendingList, origin, EntryPointId);
                c.PeopleId = p.PeopleId;

                if (c.BankAccount.HasValue())
                {
                    var ci = DbUtil.Db.CardIdentifiers.SingleOrDefault(k => k.Id == c.BankAccount);
                    if (ci == null)
                    {
                        ci = new CardIdentifier
                        {
                            Id = c.BankAccount,
                            CreatedOn = Util.Now
                        };
                        DbUtil.Db.CardIdentifiers.InsertOnSubmit(ci);
                    }
                    ci.PeopleId = p.PeopleId;
                }
                DbUtil.Db.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};
        }
Example #4
0
        private JsonResult AddContributor(int id, SearchModel m, int origin)
        {
            if (id > 0)
            {
                var p = m.List[0];
                var c = DbUtil.Db.Contributions.Single(cc => cc.ContributionId == id);
                AddPerson(p, m.List, origin, m.EntryPointId);
                c.PeopleId = p.PeopleId;

                if (c.BankAccount.HasValue())
                {
                    var ci = DbUtil.Db.CardIdentifiers.SingleOrDefault(k => k.Id == c.BankAccount);
                    if (ci == null)
                    {
                        ci = new CardIdentifier
                        {
                            Id = c.BankAccount,
                            CreatedOn = Util.Now,
                        };
                        DbUtil.Db.CardIdentifiers.InsertOnSubmit(ci);
                    }
                    ci.PeopleId = p.PeopleId;
                }
                DbUtil.Db.SubmitChanges();
                return Json(new { close = true, how = "addselected", cid = id, pid = p.PeopleId, name = p.person.Name2 });
            }
            return Json(new { close = true, how = "addselected" });
        }
Example #5
0
		private void detach_CardIdentifiers(CardIdentifier entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}