Ignore:
Timestamp:
02/04/21 21:46:29 (20 months ago)
Author:
Dimitar Slezenkovski <dslezenkovski@…>
Branches:
master
Children:
ac51326
Parents:
de9d697
Message:

Update searches, fix bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoRepo/Repository.cs

    rde9d697 rafefe75  
    6363            return Pandemic;
    6464        }
    65 
    66         public async Task<IEnumerable<Pharmacy>> GetPharmacies()
    67         {
    68             var Pharmacies = await _context.Pharmacies.Take(5).ToListAsync();
     65        public async Task<List<Pharmacy>> GetPharmacies()
     66        {
     67            var Pharmacies = await _context.Pharmacies.Select(x => new Pharmacy
     68            {
     69                Name = x.Name,
     70                Location = x.Location,
     71                Address = x.Address,
     72                WorkAllTime = x.WorkAllTime,
     73                PheadId = x.PheadId
     74            }).Take(5).ToListAsync();
    6975            return Pharmacies;
    7076        }
     
    8591        {
    8692            var SearchQuery = await _context.HealthFacilities
    87             .Where(x => x.Name.Contains(query))
     93            .Where(x => x.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
    8894            .OrderBy(x => x.Name).ToListAsync();
    8995
     
    94100        {
    95101            var SearchQuery = await _context.Medicines
    96             .Where(x => x.Name.Contains(query))
     102            .Where(x => x.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
    97103            .OrderBy(x => x.Name).ToListAsync();
    98104
     
    102108        public async Task<IEnumerable<Pharmacy>> SearchPharmacies(string query)
    103109        {
    104             var SearchQuery = await _context.Pharmacies.Take(5)
    105             .Where(x => x.Name.Contains(query))
     110            var SearchQuery = await _context.Pharmacies
     111            .Where(x => x.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
    106112            .OrderBy(x => x.Name).ToListAsync();
    107113
     
    111117        public async Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query)
    112118        {
    113             var SearchQuery = await _context.HealthcareWorkers.Take(5)
    114             .Where(x => x.Name.Contains(query))
     119            var SearchQuery = await _context.HealthcareWorkers
     120            .Where(x => x.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
    115121            .OrderBy(x => x.Name).ToListAsync();
    116122
     
    291297            }
    292298        }
     299
     300        public async Task<List<PharmacyHeadMedicine>> GetAllPHMedicines()
     301        {
     302            var list = await _context.PharmacyHeadMedicines.ToListAsync();
     303            return list;
     304        }
    293305    }
    294306}
Note: See TracChangeset for help on using the changeset viewer.