public ActionResult AddContactReceived(int id) { var p = DbUtil.Db.LoadPersonById(id); DbUtil.LogActivity("Adding contact to: {0}".Fmt(p.Name)); var c = new CmsData.Contact { CreatedDate = Util.Now, CreatedBy = Util.UserId1, ContactDate = Util.Now.Date, ContactTypeId = 99, ContactReasonId = 99, }; DbUtil.Db.Contacts.InsertOnSubmit(c); DbUtil.Db.SubmitChanges(); var pc = new Contactee { PeopleId = p.PeopleId, ContactId = c.ContactId }; DbUtil.Db.Contactees.InsertOnSubmit(pc); DbUtil.Db.SubmitChanges(); return(Content("/Contact.aspx?id=" + c.ContactId)); }
private ReturnResult AddContactees(int id, int origin) { var c = DbUtil.Db.Contacts.SingleOrDefault(ct => ct.ContactId == id); if (c != null) { foreach (var p in PendingList) { AddPerson(p, PendingList, OriginCode.Visit, EntryPointId); var ctee = c.contactees.SingleOrDefault(ct => ct.ContactId == id && ct.PeopleId == p.Person.PeopleId); if (ctee == null) { ctee = new Contactee { ContactId = id, PeopleId = p.Person.PeopleId }; c.contactees.Add(ctee); DbUtil.LogActivity("AddContactee " + id, peopleid: p.PeopleId); } } DbUtil.Db.SubmitChanges(); } return(new ReturnResult { close = true, from = AddContext, cid = id }); }
private JsonResult AddContactees(int id, SearchAddModel m, int origin) { if (id > 0) { var c = DbUtil.Db.Contacts.Single(ct => ct.ContactId == id); foreach (var p in m.List) { AddPerson(p, m.List, OriginCode.Visit, m.EntryPointId); var ctee = c.contactees.SingleOrDefault(ct => ct.ContactId == id && ct.PeopleId == p.person.PeopleId); if (ctee == null) { ctee = new Contactee { ContactId = id, PeopleId = p.person.PeopleId, }; c.contactees.Add(ctee); } } DbUtil.Db.SubmitChanges(); } return(Json(new { close = true, how = "addselected" })); }