private static HashSet<string> GetISSNs(DeleteViewModel model) { return ParseISSNs(model.ISSNs); }
public ActionResult Delete(DeleteViewModel model) { if (this.ModelState.IsValid) { var journals = this.journalRepository.All; var issns = GetISSNs(model); var journalsISSNs = journals.Select(j => j.ISSN).ToSet(StringComparer.InvariantCultureIgnoreCase); var issnsFound = issns.Intersect(journalsISSNs).ToList(); var issnsNotFound = issns.Except(journalsISSNs).ToList(); var journalsToDelete = journals.Where(j => issnsFound.Contains(j.ISSN)).ToList(); foreach (var journal in journalsToDelete) { this.journalRepository.Delete(journal); } this.journalRepository.Save(); this.Session[FoundISSNsSessionKey] = issnsFound; this.Session[NotFoundISSNsSessionKey] = issnsNotFound; return this.RedirectToAction("Deleted"); } return this.View(model); }