Changes in / [6e6f04b:dae4cde]
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/PHRepo.cs
r6e6f04b rdae4cde 61 61 user.Password = pharmacyHead.Password; 62 62 } 63 foreach(var pharmacy in pharmacyHead.Pharmacies)63 /*if (EditedPHead.Pharmacies != null) 64 64 { 65 if (!EditedPHead.Pharmacies.Contains(pharmacy)) 65 if (EditedPHead.Pharmacies.Count() > 0) 66 if (!EditedPHead.Pharmacies.Equals(pharmacyHead.Pharmacies)) 67 EditedPHead.Pharmacies = pharmacyHead.Pharmacies; 68 } 69 if (EditedPHead.Medicines != null) 70 { 71 if (EditedPHead.Medicines.Count() > 0) 66 72 { 67 pharmacy.PheadId = EditedPHead.Id;68 pharmacy.PharmacyHead = EditedPHead;69 EditedPHead.Pharmacies.Add(pharmacy);73 if (!EditedPHead.Medicines.Equals(pharmacyHead.Medicines)) 74 EditedPHead.Medicines = pharmacyHead.Medicines; 75 70 76 } 71 }72 _context.Entry(EditedPHead).State = EntityState.Modified;73 77 78 }*/ 79 74 80 _context.SaveChanges(); 75 81 } … … 147 153 public PharmacyHead GetPharmacyHead(string head) 148 154 { 149 var phead = _context.PharmacyHeads.Where(x => x.Email.Equals(head)). Include(x => x.Pharmacies).FirstOrDefault();155 var phead = _context.PharmacyHeads.Where(x => x.Email.Equals(head)).FirstOrDefault(); 150 156 return phead; 151 157 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r6e6f04b rdae4cde 270 270 public async Task RemovePharmacyHead(int Id) 271 271 { 272 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id). Include(x => x.Pharmacies).Include(x => x.Medicines).FirstOrDefaultAsync();272 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id).FirstOrDefaultAsync(); 273 273 var user = await _context.Users.Where(x => x.Email.Equals(PHead.Email)).FirstOrDefaultAsync(); 274 var PHreqs = await _context.PHRequests.Where(x => x.Head.Id.Equals(PHead.Id)).FirstOrDefaultAsync();275 PHead.Pharmacies.Select(x => x.PheadId = null);276 //PHead.Pharmacies.Select(x => x.PharmacyHead = null);277 _context.PHRequests.Remove(PHreqs);278 274 _context.PharmacyHeads.Remove(PHead); 279 275 _context.Users.Remove(user); -
FarmatikoServices/Services/PHService.cs
r6e6f04b rdae4cde 86 86 if (!pharmacyHead.Medicines.Equals(PHMedicines)) 87 87 { 88 /* 89 * USELESS 90 * if (pharmacyHead.Medicines.Count() == 0) 88 //phead.Medicines = pharmacyHead.Medicines; 89 if (pharmacyHead.Medicines.Count() == 0) 91 90 { 92 91 phead.Medicines = null; … … 96 95 _iPHRepo.DeletePHMedicine(PHMId, phId, medId); 97 96 return; 98 } */97 } 99 98 if (phead.Medicines != null && phead.Medicines.Count() > 0) 100 99 { … … 120 119 Medicine = medicine 121 120 }; 122 121 123 122 bool ifExists = phead.Medicines.Contains(phm); 124 123 if (!ifExists) … … 154 153 } 155 154 } 155 156 156 PharmacyHead head = new PharmacyHead() 157 157 { 158 158 Name = pharmacyHead.Name, 159 159 Email = pharmacyHead.Email, 160 Password = pharmacyHead.Password, 161 Medicines = phead.Medicines, 162 Pharmacies = phead.Pharmacies 160 Password = pharmacyHead.Password 163 161 }; 164 if (!phead.Name.Equals(head.Name) && !phead.Password.Equals(head.Email)) 162 163 if (pharmacyHead.Pharmacies != null) 164 { 165 if (pharmacyHead.Pharmacies.Count() > 0) 166 { 167 phead.Pharmacies = pharmacyHead.Pharmacies; 168 head.Pharmacies = pharmacyHead.Pharmacies; 169 } 170 } 171 172 if (!phead.Equals(head)) 165 173 { 166 174 await _iPHRepo.UpdatePharmacyHead(head); 167 175 } 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); 185 } 186 } 187 } 188 else throw new Exception("Cannot update pharmacy head since there was no changes."); 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."); 189 179 } 190 180 public async Task<bool> Add(PharmacyHeadDto pharmacyHead)
Note:
See TracChangeset
for help on using the changeset viewer.