protected void Page_Load(object sender, EventArgs e) { Entity = db.HoldingPens.Single(c => c.ID.ToString() == Request.QueryString["id"]); Dictionary <byte, string> comparibles = new Dictionary <byte, string>(); comparibles.Add((byte)CRM_Person.SearchKeys.DoB, ""); comparibles.Add((byte)CRM_Person.SearchKeys.PrimaryEmail, Entity.Email); comparibles.Add((byte)CRM_Person.SearchKeys.Postcode, Entity.Postcode); comparibles.Add((byte)CRM_Person.SearchKeys.Telephone, Entity.Telephone); comparibles.Add((byte)CRM_Person.SearchKeys.Fullname, Entity.Firstname + " " + Entity.Lastname); if (!Page.IsPostBack) { lnkNextRecord.Text += " (" + (HoldingPen.BaseSet(db).Count() - 1 - HoldingPen.BaseSet(db).ToList().IndexOf(Entity)) + " remaining)"; var dupes = from p in CRM_Person.BaseSet(db) where p.SearchDictionary.Any(c => comparibles.ContainsKey(c.Key) && comparibles[c.Key].Trim() != "" && c.Value.ToLower().Trim() == (comparibles[c.Key].ToLower().Trim())) orderby p.SearchDictionary.Where(c => comparibles.ContainsKey(c.Key) && comparibles[c.Key].Trim() != "" && c.Value.ToLower().Trim() == (comparibles[c.Key])).Count() descending select(object) p; lvItems.DataSource = dupes.Take(20); lvItems.DataBind(); ddlTitle.DataSource = from p in db.CRM_Titles select p; ddlTitle.DataBind(); PopulateFields(); } }
protected void lnkNextRecord_Click(object sender, EventArgs e) { var baseSet = HoldingPen.BaseSet(db).ToList(); int indexOf = baseSet.IndexOf(Entity); db.HoldingPens.DeleteOnSubmit(Entity); db.SubmitChanges(); if (indexOf != baseSet.Count - 1) { NoticeManager.SetMessage("Deleted temporary merge record and moved to next record", baseSet[indexOf + 1].DetailsURL); } else { NoticeManager.SetMessage("There are no further merge records", "list.aspx"); } }