public static async Task <bool> CheckForSectionAsync(DescDBContext dBContext, SectionInfo section) { bool recordExists; if (section.ID != 0) { recordExists = await dBContext.Sections .Where(x => x.ID == section.ID) .AnyAsync().ConfigureAwait(true); } else if (section.ParentTextID != "") { recordExists = await dBContext.Sections .Where(x => x.ParentTextID == section.ParentTextID) .AnyAsync().ConfigureAwait(true); } else if (section.ID == 0) { recordExists = await dBContext.Sections .Where(x => section.Equals(x)) .AnyAsync().ConfigureAwait(true); } else { return(false); } return(recordExists); }
public SectionInfo GetExistingElseAddAndGetCurrentSection(SectionInfo section) { var matchedSection = Sections.Where(x => section.Equals(x)).FirstOrDefault(); if (matchedSection != null) { return(matchedSection); } Sections.Add(section); return(section); }
public static SectionInfo GetSectionInfoFromCollection(ICollection <SectionInfo> sections, SectionInfo section) { return(sections.Where(record => section.Equals(record)).FirstOrDefault()); }