public static string ResolveCheck(int checkNum) { string status; using (var dbCtx = new MSMEntities()) { var longUnmatched = dbCtx.Set <ResearchCheck>(); var check = (from lu in longUnmatched where lu.Num == checkNum select lu).FirstOrDefault(); if (check == null) { status = string.Format("<p>Could not find check with number {0} in research table.<p>", checkNum); } else { longUnmatched.Remove(check); dbCtx.SaveChanges(); status = string.Format("<p>Removed from research table:<br/> Date: {0}<br/> Record ID: {1}<br/> Interview Record ID: {2}<br/> Name: {3}<br/> Check number: {4}<br/> Service: {5}</p>", check.Date.ToString("d"), check.RecordID, check.InterviewRecordID, check.Name, check.Num, check.Service); } return(status); } }
private static void AppendToResearchChecks(List <Check> checks) { using (var dbCtx = new MSMEntities()) { var longUnmatched = dbCtx.Set <ResearchCheck>(); foreach (Check check in checks) { ResearchCheck existing = (from c in longUnmatched where c.Num == check.Num select c).FirstOrDefault(); if (existing == null && !IsKnownDisposition(check.Num)) { ResearchCheck unm = new ResearchCheck { RecordID = check.RecordID, InterviewRecordID = check.InterviewRecordID, Num = check.Num, Name = check.Name, Date = check.Date, Service = check.Service, Matched = false }; longUnmatched.Add(unm); } } dbCtx.SaveChanges(); } }
private static void DeleteMarkedChecks() { using (var dbCtx = new MSMEntities()) { dbCtx.ResearchChecks.RemoveRange(dbCtx.ResearchChecks.Where(lu => lu.Matched == true)); dbCtx.SaveChanges(); } }
public static void MarkResolvedChecks() { using (var dbCtx = new MSMEntities()) { var longUnmatched = dbCtx.Set <ResearchCheck>(); foreach (ResearchCheck lu in longUnmatched) { if (IsResolved(lu.Num) || IsResolved(-lu.Num)) { lu.Matched = true; } } dbCtx.SaveChanges(); } }