public ActionResult Run(string submit, bool? Delete, MergeModel m) { if (submit.StartsWith("Merge Fields")) { DbUtil.LogActivity("Merging Fields from {0} to {1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId)); m.Update(); } if (submit == "Merge Fields and Move Related Records") { DbUtil.LogActivity("Moving records from {0} to {1}".Fmt(m.pi[0].PeopleId, m.pi[1].PeopleId)); m.Move(); if (Delete == true) { DbUtil.LogActivity("Deleting Record during Merge {0}".Fmt(m.pi[0].PeopleId)); m.Delete(); } } if (submit == "Toggle Not Duplicate") { if (m.pi[0].notdup || m.pi[1].notdup) { var dups = DbUtil.Db.PeopleExtras.Where(ee => ee.Field == "notdup" && (ee.PeopleId == m.pi[0].PeopleId || ee.PeopleId == m.pi[1].PeopleId)); DbUtil.Db.PeopleExtras.DeleteAllOnSubmit(dups); } else { m.pi[0].person.AddEditExtraInt("notdup", m.pi[1].PeopleId); m.pi[1].person.AddEditExtraInt("notdup", m.pi[0].PeopleId); } DbUtil.Db.SubmitChanges(); return Redirect("/Merge/Index?PeopleId1={0}&PeopleId2={1}".Fmt(m.pi[0].PeopleId,m.pi[1].PeopleId)); } return Redirect("/Person/Index/" + m.pi[1].PeopleId); }
public ActionResult MergeFieldsAndMoveRelated(MergeModel m) { m.LogMerge("Merge and move related"); m.Update(); m.Move(); return Redirect("/Person2/" + m.pi[1].PeopleId); }
public ActionResult Run(string submit, bool? Delete, MergeModel m) { var mh = new MergeHistory { FromId = m.pi[0].PeopleId, ToId = m.pi[1].PeopleId, FromName = m.pi[0].person.Name, ToName = m.pi[1].person.Name, WhoId = Util.UserPeopleId, WhoName = Util.UserFullName, Action = submit + (Delete == true ? " + Delete" : ""), Dt = DateTime.Now }; DbUtil.Db.MergeHistories.InsertOnSubmit(mh); if (submit.StartsWith("Merge Fields")) { DbUtil.LogActivity($"Merging Fields from {m.pi[0].PeopleId} to {m.pi[1].PeopleId}"); m.Update(); } if (submit == "Merge Fields and Move Related Records") { DbUtil.LogActivity($"Moving records from {m.pi[0].PeopleId} to {m.pi[1].PeopleId}"); m.Move(); if (Delete == true) { DbUtil.LogActivity($"Deleting Record during Merge {m.pi[0].PeopleId} to {m.pi[1].PeopleId}"); m.Delete(); } } if (submit == "Toggle Not Duplicate") { if (m.pi[0].notdup || m.pi[1].notdup) { var dups = DbUtil.Db.PeopleExtras.Where(ee => ee.Field == "notdup" && (ee.PeopleId == m.pi[0].PeopleId || ee.PeopleId == m.pi[1].PeopleId)); DbUtil.Db.PeopleExtras.DeleteAllOnSubmit(dups); } else { m.pi[0].person.AddEditExtraInt("notdup", m.pi[1].PeopleId); m.pi[1].person.AddEditExtraInt("notdup", m.pi[0].PeopleId); } DbUtil.Db.SubmitChanges(); return Redirect($"/Merge/{m.pi[0].PeopleId}/{m.pi[1].PeopleId}"); } return Redirect("/Person2/" + m.pi[1].PeopleId); }