Changeset 1db5673 for FarmatikoData/FarmatikoRepo
- Timestamp:
- 11/14/20 12:27:30 (4 years ago)
- Branches:
- master
- Children:
- 68454c6
- Parents:
- ad60966
- Location:
- FarmatikoData/FarmatikoRepo
- Files:
-
- 2 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 } -
FarmatikoData/FarmatikoRepo/Repository.cs
rad60966 r1db5673 41 41 } 42 42 43 public async Task<IEnumerable<Medicine>> GetMedicines() 44 { 45 var Medicines = await _context.Medicines.Take(3).ToListAsync(); 43 public async Task<IEnumerable<Medicine>> GetMedicinesAsync() 44 { 45 var Medicines = await _context.Medicines.Select(x => new Medicine 46 { 47 Name = x.Name, 48 Strength = x.Strength, 49 Form = x.Form, 50 WayOfIssuing = x.WayOfIssuing, 51 Manufacturer = x.Manufacturer, 52 Price = x.Price, 53 Packaging = x.Packaging 54 55 }).Take(3).ToListAsync(); 46 56 return Medicines; 47 57 } … … 205 215 public Task UpdateMedicine(Medicine medicine) 206 216 { 207 throw new System.NotImplementedException();217 throw new NotImplementedException(); 208 218 } 209 219 … … 227 237 return users; 228 238 } 239 240 public User GetRole(string userName) 241 { 242 var user = _context.Users.Where(x => x.Email.Equals(userName)).FirstOrDefault(); 243 return user; 244 } 245 246 public ICollection<Medicine> GetMedicines() 247 { 248 var Medicines = _context.Medicines.Select(x => new Medicine 249 { 250 Id = x.Id, 251 Name = x.Name, 252 Strength = x.Strength, 253 Form = x.Form, 254 WayOfIssuing = x.WayOfIssuing, 255 Manufacturer = x.Manufacturer, 256 Price = x.Price, 257 Packaging = x.Packaging, 258 MedicineList = x.MedicineList 259 260 }).ToList(); 261 return Medicines; 262 } 263 264 public ICollection<PharmacyHeadMedicine> GetPHMedicines(string email) 265 { 266 var head = _context.PharmacyHeads.Where(x => x.Email.Equals(email)).FirstOrDefault(); 267 var phmeds = _context.PharmacyHeadMedicines.Where(x => x.PheadId == head.Id).ToList(); 268 return phmeds; 269 } 229 270 } 230 271 }
Note:
See TracChangeset
for help on using the changeset viewer.