internal static List <LeafletDTO> LeafletDownloadUrlBy(string[] md5) { using (SaleFinderDbContext context = new SaleFinderDbContext()) { var leaflets = context.Leaflets.Where(leaflet => md5.Any(x => x == leaflet.Hash)); return(leaflets.ProjectToType <LeafletDTO>().ToList()); } }
public static void AddLeaflet(LeafletModel leafletModel) { using (SaleFinderDbContext context = new SaleFinderDbContext()) { context.Leaflets.Add(leafletModel); context.SaveChanges(); } }
public static void InitDatabase() { using (SaleFinderDbContext context = new SaleFinderDbContext()) { context.Database.Migrate(); context.SaveChanges(); } }
public static void DeleteLeaflets(string groupName) { using (SaleFinderDbContext context = new SaleFinderDbContext()) { var leafletsToDelete = context.Leaflets.Where(x => x.GroupName == groupName).ToList(); context.Leaflets.RemoveRange(leafletsToDelete); context.SaveChanges(); } }
public static IList <LeafletModel> FindInLeaflet(string groupName, string[] keyWords) { using (SaleFinderDbContext context = new SaleFinderDbContext()) { //var test = context.Leaflets.ToList().Where(x => x.GroupName == groupName && // x.Pages.Count(y => keyWords.Any(k => y.Text.Contains(k))) > 0 //).ToList(); var test = context.Leaflets.Where(leaflet => leaflet.GroupName == groupName).SelectMany(leaflet => leaflet.Pages) .Where(leafletpage => keyWords.Any(keyword => leafletpage.Text.Contains(keyword))) .Select(result => new SaleResult { GroupName = groupName, PageNumber = result.PageNumber }).ToList(); //test.Select(searchresult => new SaleResult { GroupName = groupName, KeyWord = , }) return(null); }; }