Changeset db484c9 for FarmatikoData/FarmatikoRepo
- Timestamp:
- 01/26/21 10:33:09 (4 years ago)
- Branches:
- master
- Children:
- 7d80751
- Parents:
- 8e74e2f
- Location:
- FarmatikoData/FarmatikoRepo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/AdminRepo.cs
r8e74e2f rdb484c9 27 27 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads() 28 28 { 29 var PHeads = await _context.PharmacyHeads.OrderBy(x => x.Name).ToListAsync(); 29 var PHeads = await _context.PharmacyHeads 30 .Include(x => x.Medicines) 31 .Include(x => x.Pharmacies) 32 .OrderBy(x => x.Name) 33 .ToListAsync(); 30 34 return PHeads; 31 35 } 32 36 //POST 33 public void RemoveClaimRequest(int Id)37 public async void RemoveClaimRequest(int Id) 34 38 { 35 39 var req = _context.PHRequests.Where(x => x.Id == Id).FirstOrDefault(); 36 40 _context.PHRequests.Remove(req); 37 _context.SaveChanges();41 await _context.SaveChangesAsync(); 38 42 } 39 43 } -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r8e74e2f rdb484c9 24 24 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo() 25 25 { 26 var PHeadInfo = await _context.PharmacyHeads.Take(10).Where(x => x.DeletedOn == null) 26 var PHeadInfo = await _context.PharmacyHeads.Take(10) 27 .Where(x => x.DeletedOn == null) 27 28 .Select(x => new PharmacyHead 28 29 { … … 31 32 Email = x.Email, 32 33 Password = x.Password, 33 MedicineList = x.MedicineList, 34 PharmaciesList = x.PharmaciesList 34 Pharmacies = x.Pharmacies, 35 Medicines = x.Medicines 36 35 37 }).ToListAsync(); 36 38 return PHeadInfo; … … 41 43 var Phead = await _context.PharmacyHeads.Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 42 44 var EditedPHead = await _context.PharmacyHeads.AsNoTracking<PharmacyHead>().Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 43 EditedPHead.Email = pharmacyHead.Email; 44 EditedPHead.Name = pharmacyHead.Name; 45 EditedPHead.Password = pharmacyHead.Password; 46 /*if (pharmacyHead.MedicineList.Count() == 0) 47 pharmacyHead.MedicineList = null;*/ 48 EditedPHead.MedicineList = pharmacyHead.MedicineList; 49 EditedPHead.PharmaciesList = pharmacyHead.PharmaciesList; 50 EditedPHead.PHMedicineList = pharmacyHead.PHMedicineList; 51 //_context.Entry<PharmacyHead>(Phead).State = EntityState.Detached; 52 //Phead = EditedPHead; 45 46 if (!EditedPHead.Email.Equals(pharmacyHead.Email)) 47 EditedPHead.Email = pharmacyHead.Email; 48 49 if (!EditedPHead.Name.Equals(pharmacyHead.Name)) 50 EditedPHead.Name = pharmacyHead.Name; 51 52 if (!EditedPHead.Password.Equals(pharmacyHead.Password)) 53 EditedPHead.Password = pharmacyHead.Password; 54 55 if (!EditedPHead.Pharmacies.Equals(pharmacyHead.Pharmacies)) 56 EditedPHead.Pharmacies = pharmacyHead.Pharmacies; 57 58 if (!EditedPHead.Medicines.Equals(pharmacyHead.Medicines)) 59 EditedPHead.Medicines = pharmacyHead.Medicines; 60 53 61 await _context.SaveChangesAsync(); 54 62 } … … 81 89 public PharmacyHead GetPharmacyHeadByUserName(string userName) 82 90 { 91 92 83 93 var PHead = _context.PharmacyHeads 84 94 .Where(x => x.Email.Equals(userName)) 85 .FirstOrDefault(); 95 .Select(x => new PharmacyHead 96 { 97 Email = x.Email, 98 Name = x.Name, 99 Password = x.Password, 100 Medicines = x.Medicines, 101 Pharmacies = x.Pharmacies 102 }).FirstOrDefault(); 103 104 86 105 87 106 return PHead; … … 90 109 public List<PharmacyHeadMedicine> GetPharmacyHeadMedicines(string email) 91 110 { 92 /*var meds = _context.Medicines.ToList();93 var medicines = Medicines;*/94 111 var Phead = _context.PharmacyHeads.Where(x => x.Email.Equals(email)).FirstOrDefault(); 95 var Medicines = _context.PharmacyHeadMedicines.Where(x => x.PheadId == Phead.Id).ToList(); 96 /*.Select(x => x.Head.MedicineList) 97 .SelectMany(mList => mList) 98 .ToList();*/ 112 var Medicines = _context.PharmacyHeadMedicines.Select(x => new PharmacyHeadMedicine 113 { 114 PheadId = x.PheadId, 115 Head = x.Head, 116 MedicineId = x.MedicineId, 117 Medicine = x.Medicine 118 }).ToList(); 119 if (Medicines == null || Medicines == default) 120 Medicines = null; 121 var meds = Medicines.Where(x => x.PheadId == Phead.Id).ToList(); 99 122 100 101 return Medicines; 123 return meds; 102 124 } 103 125 -
FarmatikoData/FarmatikoRepo/Repository.cs
r8e74e2f rdb484c9 86 86 var SearchQuery = await _context.HealthFacilities 87 87 .Where(x => x.Name.Contains(query)) 88 .OrderBy(x => x.Name).T ake(3).ToListAsync();88 .OrderBy(x => x.Name).ToListAsync(); 89 89 90 90 return SearchQuery; … … 95 95 var SearchQuery = await _context.Medicines 96 96 .Where(x => x.Name.Contains(query)) 97 .OrderBy(x => x.Name).T ake(5).ToListAsync();97 .OrderBy(x => x.Name).ToListAsync(); 98 98 99 99 return SearchQuery; … … 104 104 var SearchQuery = await _context.Pharmacies.Take(5) 105 105 .Where(x => x.Name.Contains(query)) 106 .OrderBy(x => x.Name).T ake(5).ToListAsync();106 .OrderBy(x => x.Name).ToListAsync(); 107 107 108 108 return SearchQuery; … … 113 113 var SearchQuery = await _context.HealthcareWorkers.Take(5) 114 114 .Where(x => x.Name.Contains(query)) 115 .OrderBy(x => x.Name).T ake(5).ToListAsync();115 .OrderBy(x => x.Name).ToListAsync(); 116 116 117 117 return SearchQuery; … … 170 170 Facility.Phone = healthFacility.Phone; 171 171 Facility.Type = healthFacility.Type; 172 _context.SaveChanges();172 await _context.SaveChangesAsync(); 173 173 } 174 174 175 175 public async Task RemoveMedicine(Medicine medicine) 176 176 { 177 await Task.Run(() => _context.Medicines.Remove(medicine));178 _context.SaveChanges();177 _context.Medicines.Remove(medicine); 178 await _context.SaveChangesAsync(); 179 179 } 180 180 … … 190 190 Pandemic.TotalGlobal = pandemic.TotalGlobal; 191 191 Pandemic.TotalMK = pandemic.TotalMK; 192 _context.SaveChanges();192 await _context.SaveChangesAsync(); 193 193 } 194 194 195 195 public async Task RemovePharmacy(Pharmacy pharmacy) 196 196 { 197 await Task.Run(() => _context.Pharmacies.Remove(pharmacy));198 _context.SaveChanges();197 _context.Pharmacies.Remove(pharmacy); 198 await _context.SaveChangesAsync(); 199 199 } 200 200 //not impl … … 211 211 Pharmacy.WorkAllTime = pharmacy.WorkAllTime; 212 212 Pharmacy.Address = pharmacy.Address; 213 _context.SaveChanges();214 } 215 // ke vidime213 await _context.SaveChangesAsync(); 214 } 215 //not implemented, not needed 216 216 public Task UpdateMedicine(Medicine medicine) 217 217 { … … 223 223 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id).FirstOrDefaultAsync(); 224 224 PHead.DeletedOn = DateTime.UtcNow; 225 _context.SaveChanges();225 await _context.SaveChangesAsync(); 226 226 } 227 227 … … 236 236 UserRole = x.UserRole 237 237 }); 238 238 239 return users; 239 240 } … … 257 258 Price = x.Price, 258 259 Packaging = x.Packaging, 259 Medicine List = x.MedicineList260 Medicines = x.Medicines 260 261 261 262 }).ToList(); … … 266 267 { 267 268 var head = _context.PharmacyHeads.Where(x => x.Email.Equals(email)).FirstOrDefault(); 268 var phmeds = _context.PharmacyHeadMedicines.Where(x => x.PheadId == head.Id). ToList();269 var phmeds = _context.PharmacyHeadMedicines.Where(x => x.PheadId == head.Id).Include(x => x.Medicine).ToList(); 269 270 return phmeds; 270 271 }
Note:
See TracChangeset
for help on using the changeset viewer.