Changeset d23bf72 for FarmatikoData/FarmatikoRepo
- Timestamp:
- 11/05/20 06:57:35 (4 years ago)
- Branches:
- master
- Children:
- afc9a9a
- Parents:
- 1f4846d
- Location:
- FarmatikoData/FarmatikoRepo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/AdminRepo.cs
r1f4846d rd23bf72 31 31 } 32 32 //POST 33 public void RemoveClaimRequest( RequestPharmacyHead req)33 public void RemoveClaimRequest(int Id) 34 34 { 35 var req = _context.PHRequests.Where(x => x.Id == Id).FirstOrDefault(); 35 36 _context.PHRequests.Remove(req); 36 37 _context.SaveChanges(); -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r1f4846d rd23bf72 71 71 await _context.SaveChangesAsync(); 72 72 } 73 74 public PharmacyHead GetPharmacyHeadByUserName(string userName) 75 { 76 return _context.PharmacyHeads 77 .Where(x => x.Email.Equals(userName)) 78 .FirstOrDefault(); 79 } 73 80 } 74 81 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r1f4846d rd23bf72 19 19 public async Task<IEnumerable<HealthcareWorker>> GetAllWorkers() 20 20 { 21 var Workers = await Task.Run(() => _context.HealthcareWorkers.Take(10));21 var Workers = await _context.HealthcareWorkers.Take(5).ToListAsync(); 22 22 return Workers; 23 23 } … … 25 25 public async Task<IEnumerable<HealthFacility>> GetFacilities() 26 26 { 27 var Facilities = await Task.Run(() => _context.HealthFacilities.Take(10));27 var Facilities = await _context.HealthFacilities.Take(5).ToListAsync(); 28 28 return Facilities; 29 29 } … … 43 43 public async Task<IEnumerable<Medicine>> GetMedicines() 44 44 { 45 var Medicines = await Task.Run(() => _context.Medicines.Take(10));45 var Medicines = await _context.Medicines.Take(3).ToListAsync(); 46 46 return Medicines; 47 47 } … … 49 49 public async Task<Pandemic> GetPandemic() 50 50 { 51 var Pandemic = await Task.Run(() => _context.Pandemics.FirstOrDefault());51 var Pandemic = await _context.Pandemics.FirstOrDefaultAsync(); 52 52 return Pandemic; 53 53 } … … 55 55 public async Task<IEnumerable<Pharmacy>> GetPharmacies() 56 56 { 57 var Pharmacies = await Task.Run(() => _context.Pharmacies.Take(10));57 var Pharmacies = await _context.Pharmacies.Take(5).ToListAsync(); 58 58 return Pharmacies; 59 59 } … … 73 73 public async Task<IEnumerable<HealthFacility>> SearchFacilities(string query) 74 74 { 75 var SearchQuery = await Task.Run(() =>_context.HealthFacilities76 .Where(x => x.Name. Equals(query))77 .OrderBy(x => x.Name) );75 var SearchQuery = await _context.HealthFacilities 76 .Where(x => x.Name.Contains(query)) 77 .OrderBy(x => x.Name).Take(3).ToListAsync(); 78 78 79 79 return SearchQuery; … … 82 82 public async Task<IEnumerable<Medicine>> SearchMedicines(string query) 83 83 { 84 var SearchQuery = await Task.Run(() =>_context.Medicines85 .Where(x => x.Name. Equals(query))86 .OrderBy(x => x.Name) );84 var SearchQuery = await _context.Medicines 85 .Where(x => x.Name.Contains(query)) 86 .OrderBy(x => x.Name).Take(5).ToListAsync(); 87 87 88 88 return SearchQuery; … … 91 91 public async Task<IEnumerable<Pharmacy>> SearchPharmacies(string query) 92 92 { 93 var SearchQuery = await Task.Run(() => _context.Pharmacies94 .Where(x => x.Name. Equals(query))95 .OrderBy(x => x.Name) );93 var SearchQuery = await _context.Pharmacies.Take(5) 94 .Where(x => x.Name.Contains(query)) 95 .OrderBy(x => x.Name).Take(5).ToListAsync(); 96 96 97 97 return SearchQuery; … … 100 100 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query) 101 101 { 102 var SearchQuery = await Task.Run(() => _context.HealthcareWorkers103 .Where(x => x.Name. Equals(query))104 .OrderBy(x => x.Name) );105 106 return SearchQuery; 107 } 108 public async Task<HealthFacility>GetFacilityJSON(string healthFacility)109 { 110 var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility)).FirstOrDefault());102 var SearchQuery = await _context.HealthcareWorkers.Take(5) 103 .Where(x => x.Name.Contains(query)) 104 .OrderBy(x => x.Name).Take(5).ToListAsync(); 105 106 return SearchQuery; 107 } 108 public HealthFacility GetFacilityJSON(string healthFacility) 109 { 110 var Facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility)).FirstOrDefault(); 111 111 return Facility; 112 112 } … … 116 116 public async Task AddWorker(HealthcareWorker Worker) 117 117 { 118 await Task.Run(() => _context.HealthcareWorkers.Add(Worker));119 await _context.SaveChangesAsync();118 await _context.HealthcareWorkers.AddAsync(Worker); 119 _context.SaveChanges(); 120 120 } 121 121 122 122 public async Task AddFacility(HealthFacility healthFacility) 123 123 { 124 await Task.Run(() => _context.HealthFacilities.Add(healthFacility));125 await _context.SaveChangesAsync();124 await _context.HealthFacilities.AddAsync(healthFacility); 125 _context.SaveChanges(); 126 126 } 127 127 128 128 public async Task AddPharmacy(Pharmacy pharmacy) 129 129 { 130 await Task.Run(() => _context.Pharmacies.Add(pharmacy));131 await _context.SaveChangesAsync();130 await _context.Pharmacies.AddAsync(pharmacy); 131 _context.SaveChanges(); 132 132 } 133 133 134 134 public async Task AddPharmacyHead(PharmacyHead pharmacyHead) 135 135 { 136 await Task.Run(() => _context.PharmacyHeads.Add(pharmacyHead));137 await _context.SaveChangesAsync();136 await _context.PharmacyHeads.AddAsync(pharmacyHead); 137 _context.SaveChanges(); 138 138 } 139 139 140 140 public async Task AddMedicines(Medicine medicine) 141 141 { 142 await Task.Run(() => _context.Medicines.Add(medicine));143 await _context.SaveChangesAsync();142 await _context.Medicines.AddAsync(medicine); 143 _context.SaveChanges(); 144 144 } 145 145 146 146 public async Task AddPandemic(Pandemic pandemic) 147 147 { 148 await Task.Run(() => _context.Pandemics.Add(pandemic));149 await _context.SaveChangesAsync();148 var pand = await _context.Pandemics.AddAsync(pandemic); 149 _context.SaveChanges(); 150 150 } 151 151 152 152 public async Task UpdateFacility(HealthFacility healthFacility) 153 153 { 154 var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Id == healthFacility.Id).FirstOrDefault());154 var Facility = await _context.HealthFacilities.Where(x => x.Id == healthFacility.Id).FirstOrDefaultAsync(); 155 155 Facility.Address = healthFacility.Address; 156 156 Facility.Email = healthFacility.Email; … … 159 159 Facility.Phone = healthFacility.Phone; 160 160 Facility.Type = healthFacility.Type; 161 await _context.SaveChangesAsync();161 _context.SaveChanges(); 162 162 } 163 163 … … 165 165 { 166 166 await Task.Run(() => _context.Medicines.Remove(medicine)); 167 await _context.SaveChangesAsync();167 _context.SaveChanges(); 168 168 } 169 169 170 170 public async Task UpdatePandemic(Pandemic pandemic) 171 171 { 172 var Pandemic = await Task.Run(() => _context.Pandemics.Where(x => x.Id == pandemic.Id).FirstOrDefault());172 var Pandemic = await _context.Pandemics.Where(x => x.Id == pandemic.Id).FirstOrDefaultAsync(); 173 173 Pandemic.ActiveGlobal = pandemic.ActiveGlobal; 174 174 Pandemic.ActiveMK = pandemic.ActiveMK; … … 179 179 Pandemic.TotalGlobal = pandemic.TotalGlobal; 180 180 Pandemic.TotalMK = pandemic.TotalMK; 181 await _context.SaveChangesAsync();181 _context.SaveChanges(); 182 182 } 183 183 … … 185 185 { 186 186 await Task.Run(() => _context.Pharmacies.Remove(pharmacy)); 187 await _context.SaveChangesAsync();187 _context.SaveChanges(); 188 188 } 189 189 //not impl … … 195 195 public async Task UpadatePharmacy(Pharmacy pharmacy) 196 196 { 197 var Pharmacy = await Task.Run(() => _context.Pharmacies.Where(x => x.Id == pharmacy.Id).FirstOrDefault());197 var Pharmacy = await _context.Pharmacies.Where(x => x.Id == pharmacy.Id).FirstOrDefaultAsync(); 198 198 Pharmacy.Name = pharmacy.Name; 199 199 Pharmacy.Location = pharmacy.Location; 200 200 Pharmacy.WorkAllTime = pharmacy.WorkAllTime; 201 201 Pharmacy.Address = pharmacy.Address; 202 await _context.SaveChangesAsync();202 _context.SaveChanges(); 203 203 } 204 204 //ke vidime … … 212 212 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id).FirstOrDefaultAsync(); 213 213 PHead.DeletedOn = DateTime.UtcNow; 214 await _context.SaveChangesAsync(); 215 } 216 214 _context.SaveChanges(); 215 } 216 217 public IDictionary<string, User> GetUsers() 218 { 219 var users = _context.Users.ToDictionary(x => x.Email, x => new User 220 { 221 Id = x.Id, 222 Name = x.Name, 223 Email = x.Email, 224 Password = x.Password, 225 UserRole = x.UserRole 226 }); 227 return users; 228 } 217 229 } 218 230 }
Note:
See TracChangeset
for help on using the changeset viewer.