Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public ActionResult MergeFieldsAndMoveRelated(MergeModel m)
 {
     m.LogMerge("Merge and move related");
     m.Update();
     m.Move();
     return Redirect("/Person2/" + m.pi[1].PeopleId);
 }
Exemplo n.º 3
0
 public ActionResult Index(int PeopleId1, int PeopleId2)
 {
     var m = new MergeModel(PeopleId1, PeopleId2);
     if (m.pi.Count != 3)
         if (m.pi.Count == 2)
             if (m.pi[0].PeopleId != PeopleId1)
                 return Content($"peopleid {PeopleId1} not found");
             else
                 return Content($"peopleid {PeopleId2} not found");
         else if (m.pi.Count == 1)
             return Content("neither peopleid found");
     return View(m);
 }
Exemplo n.º 4
0
 public ActionResult Index(int peopleId1, int peopleId2)
 {
     var m = new MergeModel(peopleId1, peopleId2) { DeleteDuplicate = true };
     if (m.pi.Count != 3)
         if (m.pi.Count == 2)
             if (m.pi[0].PeopleId != peopleId1)
                 return Content($"peopleid {peopleId1} not found");
             else
                 return Content($"peopleid {peopleId2} not found");
         else if (m.pi.Count == 1)
             return Content("neither peopleid found");
     return View(m);
 }
Exemplo n.º 5
0
 public ActionResult Index(int? PeopleId1, int? PeopleId2)
 {
     if (!PeopleId1.HasValue || !PeopleId2.HasValue)
         return Content("need PeopleId1 and PeopleId2");
     var m = new MergeModel(PeopleId1.Value, PeopleId2.Value);
     if (m.pi.Count != 3)
         if (m.pi.Count == 2)
             if (m.pi[0].PeopleId != PeopleId1.Value)
                 return Content("peopleid {0} not found".Fmt(PeopleId1.Value));
             else
                 return Content("peopleid {0} not found".Fmt(PeopleId2.Value));
         else if (m.pi.Count == 1)
             return Content("neither peopleid found");
     return View(m);
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
 public ActionResult ToggleNotDuplicate(MergeModel m)
 {
     m.LogMerge("Toggle Not Duplicate");
     m.ToggleNotDuplicate();
     return Redirect($"/Merge/{m.pi[0].PeopleId}/{m.pi[1].PeopleId}");
 }
Exemplo n.º 8
0
 public ActionResult MergeFields(MergeModel m)
 {
     m.LogMerge("Merge Fields");
     m.Update();
     return Redirect("/Person2/" + m.pi[1].PeopleId);
 }