Beispiel #1
0
 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);
 }
Beispiel #2
0
 public void LogMerge(string action)
 {
     var mh = new MergeHistory
     {
         FromId = pi[0].PeopleId,
         ToId = pi[1].PeopleId,
         FromName = pi[0].person.Name,
         ToName = pi[1].person.Name,
         WhoId = Util.UserPeopleId,
         WhoName = Util.UserFullName,
         Action = $"{action}{(DeleteDuplicate ? " + Delete" : "")}",
         Dt = DateTime.Now
     };
     DbUtil.Db.MergeHistories.InsertOnSubmit(mh);
     DbUtil.LogActivity($"{action} from {pi[0].PeopleId} to {pi[1].PeopleId}");
     if (DeleteDuplicate == true)
         DbUtil.LogActivity($"Deleting Record during Merge {pi[0].PeopleId} to {pi[1].PeopleId}");
 }