Changeset 8eb1e21 for FarmatikoServices
- Timestamp:
- 02/11/21 03:49:55 (4 years ago)
- Branches:
- master
- Children:
- 6e6f04b
- Parents:
- e0cdea2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoServices/Services/PHService.cs
re0cdea2 r8eb1e21 86 86 if (!pharmacyHead.Medicines.Equals(PHMedicines)) 87 87 { 88 //phead.Medicines = pharmacyHead.Medicines; 89 if (pharmacyHead.Medicines.Count() == 0) 88 /* 89 * USELESS 90 * if (pharmacyHead.Medicines.Count() == 0) 90 91 { 91 92 phead.Medicines = null; … … 95 96 _iPHRepo.DeletePHMedicine(PHMId, phId, medId); 96 97 return; 97 } 98 }*/ 98 99 if (phead.Medicines != null && phead.Medicines.Count() > 0) 99 100 { … … 119 120 Medicine = medicine 120 121 }; 121 122 122 123 bool ifExists = phead.Medicines.Contains(phm); 123 124 if (!ifExists) … … 153 154 } 154 155 } 155 156 156 PharmacyHead head = new PharmacyHead() 157 157 { 158 158 Name = pharmacyHead.Name, 159 159 Email = pharmacyHead.Email, 160 Password = pharmacyHead.Password 160 Password = pharmacyHead.Password, 161 Medicines = phead.Medicines, 162 Pharmacies = phead.Pharmacies 161 163 }; 162 163 if (pharmacyHead.Pharmacies != null) 164 { 165 if (pharmacyHead.Pharmacies.Count() > 0) 166 { 167 phead.Pharmacies = pharmacyHead.Pharmacies; 168 head.Pharmacies = pharmacyHead.Pharmacies; 164 if (!phead.Name.Equals(head.Name) && !phead.Password.Equals(head.Email)) 165 { 166 await _iPHRepo.UpdatePharmacyHead(head); 167 } 168 List<Pharmacy> pharmacies = new List<Pharmacy>(); 169 pharmacies = phead.Pharmacies; 170 if (head.Pharmacies != null && pharmacyHead.Pharmacies != null) 171 { 172 if (head.Pharmacies.Count() > 0 && pharmacyHead.Pharmacies.Count() > 0) 173 { 174 foreach (var pharmacy in pharmacyHead.Pharmacies) 175 { 176 if (!head.Pharmacies.Contains(pharmacy)) 177 { 178 pharmacy.PheadId = phead.Id; 179 pharmacy.PharmacyHead = phead; 180 pharmacies.Add(pharmacy); 181 } 182 } 183 head.Pharmacies = pharmacies; 184 await _iPHRepo.UpdatePharmacyHead(head); 169 185 } 170 186 } 171 172 if (!phead.Equals(head)) 173 { 174 await _iPHRepo.UpdatePharmacyHead(head); 175 } 176 else throw new Exception("Cannot update pharmacy head since there was no changes."); 177 } 178 else throw new Exception("PharmacyHead has a null value."); 187 } 188 else throw new Exception("Cannot update pharmacy head since there was no changes."); 179 189 } 180 190 public async Task<bool> Add(PharmacyHeadDto pharmacyHead)
Note:
See TracChangeset
for help on using the changeset viewer.