Changeset 1db5673 for FarmatikoData/FarmatikoRepo/PHRepo.cs
- Timestamp:
- 11/14/20 12:27:30 (4 years ago)
- Branches:
- master
- Children:
- 68454c6
- Parents:
- ad60966
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/PHRepo.cs
rad60966 r1db5673 31 31 Email = x.Email, 32 32 Password = x.Password, 33 MedicineList s = x.MedicineLists,33 MedicineList = x.MedicineList, 34 34 PharmaciesList = x.PharmaciesList 35 35 }).ToListAsync(); … … 39 39 public async Task UpdatePharmacyHead(PharmacyHead pharmacyHead) 40 40 { 41 var EditedPHead = await _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefaultAsync(); 41 var Phead = await _context.PharmacyHeads.Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 42 var EditedPHead = await _context.PharmacyHeads.AsNoTracking<PharmacyHead>().Where(x => x.Email == pharmacyHead.Email).FirstOrDefaultAsync(); 42 43 EditedPHead.Email = pharmacyHead.Email; 43 44 EditedPHead.Name = pharmacyHead.Name; 44 45 EditedPHead.Password = pharmacyHead.Password; 45 EditedPHead.MedicineLists = pharmacyHead.MedicineLists; 46 /*if (pharmacyHead.MedicineList.Count() == 0) 47 pharmacyHead.MedicineList = null;*/ 48 EditedPHead.MedicineList = pharmacyHead.MedicineList; 46 49 EditedPHead.PharmaciesList = pharmacyHead.PharmaciesList; 50 EditedPHead.PHMedicineList = pharmacyHead.PHMedicineList; 51 //_context.Entry<PharmacyHead>(Phead).State = EntityState.Detached; 52 Phead = EditedPHead; 47 53 await _context.SaveChangesAsync(); 48 54 } … … 72 78 } 73 79 80 74 81 public PharmacyHead GetPharmacyHeadByUserName(string userName) 75 82 { 76 return_context.PharmacyHeads83 var PHead = _context.PharmacyHeads 77 84 .Where(x => x.Email.Equals(userName)) 78 85 .FirstOrDefault(); 86 87 return PHead; 88 } 89 90 public List<PharmacyHeadMedicine> GetPharmacyHeadMedicines(string email) 91 { 92 /*var meds = _context.Medicines.ToList(); 93 var medicines = Medicines;*/ 94 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();*/ 99 100 101 return Medicines; 102 } 103 104 public IEnumerable<PharmacyHead> GetPharmacyHeads() 105 { 106 var heads = _context.PharmacyHeads.ToList(); 107 return heads; 108 } 109 110 public PharmacyHead GetPharmacyHead(string head) 111 { 112 var phead = _context.PharmacyHeads.Where(x => x.Email.Equals(head)).FirstOrDefault(); 113 return phead; 114 } 115 116 public List<Pharmacy> GetPharmacies() 117 { 118 var pharms = _context.Pharmacies.ToList(); 119 return pharms; 79 120 } 80 121 }
Note:
See TracChangeset
for help on using the changeset viewer.