Exemplo n.º 1
0
 public async Task Add(Archive archive)
 {
     using (var EFR = new EFRepositoryContext())
     {
         Task EFRAdd = Task.Run(() => EFR.Files.AddRange(archive.Files));
         EFRAdd.Wait();
         EFR.Archives.Add(archive);
         await EFR.SaveChangesAsync();
     }
 }
Exemplo n.º 2
0
 public async Task Remove(Archive archive)
 {
     using (var EFR = new EFRepositoryContext())
     {
         EFR.Archives.Remove(archive);
         var filesToDelete = EFR.Files.Where(x => x.Archive.Name.Equals(archive.Name));
         EFR.Files.RemoveRange(filesToDelete);
         await EFR.SaveChangesAsync();
     }
 }
Exemplo n.º 3
0
        public async Task <List <Archive> > Load()
        {
            using (var EFR = new EFRepositoryContext())
            {
                var EFRList = await EFR.Archives.ToListAsync <Archive>();

                //var EFRFiles = EFR.Files.ToList<File>();
                return(EFRList);
            }
        }
Exemplo n.º 4
0
        public async Task <List <File> > Search(string searchString)
        {
            using (var EFR = new EFRepositoryContext())
            {
                //var returnList = EFR.Files.Where(f => f.Name.ToLower().Contains(searchString.ToLower())).SelectMany();
                //var returnList = from f in EFR.Files.Include("Archive") where f.Name.ToLower().Contains(searchString.ToLower()) select f;
                var returnList = from f in EFR.Files where f.Name.ToLower().Contains(searchString.ToLower()) select f;
                //var returnList = EFR.Files.Where(f => f.Name == searchString).Select(x => x).Include("Archive") ;

                //List<File> returnList = EFR.Files.Include("Archive").Where(f => f.Name == searchString).ToList();
                return(await returnList.Include("Archive").ToListAsync());
            }
        }