Changeset 0a694bb for FarmatikoData/FarmatikoRepo
- Timestamp:
- 02/07/21 16:25:56 (4 years ago)
- Branches:
- master
- Children:
- e0cdea2
- Parents:
- ac51326
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/Repository.cs
rac51326 r0a694bb 71 71 Address = x.Address, 72 72 WorkAllTime = x.WorkAllTime, 73 PheadId = x.PheadId 73 PheadId = x.PheadId, 74 PharmacyHead = x.PharmacyHead 74 75 }).Take(5).ToListAsync(); 75 76 return Pharmacies; … … 91 92 { 92 93 var SearchQuery = await _context.HealthFacilities 93 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)94 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 94 95 .OrderBy(x => x.Name).ToListAsync(); 95 96 … … 100 101 { 101 102 var SearchQuery = await _context.Medicines 102 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)103 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 103 104 .OrderBy(x => x.Name).ToListAsync(); 104 105 … … 109 110 { 110 111 var SearchQuery = await _context.Pharmacies 111 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)112 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 112 113 .OrderBy(x => x.Name).ToListAsync(); 113 114 … … 118 119 { 119 120 var SearchQuery = await _context.HealthcareWorkers 120 .Where(x => x.Name. IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)121 .Where(x => x.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) 121 122 .OrderBy(x => x.Name).ToListAsync(); 122 123 … … 154 155 if (pharmacyHead.Id == 0) 155 156 { 156 var pheads = await _context.PharmacyHeads.ToListAsync(); 157 if (!pheads.Select(x => x.Equals(pharmacyHead)).FirstOrDefault()) 157 var pheads = await _context.PharmacyHeads.Select(x => new PharmacyHead 158 { 159 Name = x.Name, 160 Email = x.Email 161 }).ToListAsync(); 162 var pheadusr = pheads.Where(x => x.Email.Equals(pharmacyHead.Email)).ToList(); 163 if (pheadusr == null || pheadusr.Count() == 0) 158 164 { 159 165 await _context.PharmacyHeads.AddAsync(pharmacyHead); … … 285 291 } 286 292 287 public async Task AddUser(User user)293 public async Task<bool> AddUser(User user) 288 294 { 289 295 if (user.Id == 0) 290 296 { 291 var users = await _context.Users.ToListAsync(); 292 if (!users.Select(x => x.Equals(user)).FirstOrDefault()) 297 var users = await _context.Users.Select(x => new User 298 { 299 Name = x.Name, 300 Email = x.Email, 301 Password = x.Password, 302 UserRole = x.UserRole 303 }).ToListAsync(); 304 var usr = users.Where(x => x.Email.Equals(user.Email)).ToList(); 305 if (usr != null || usr.Count() > 0) 306 { 307 return true; 308 } 309 else 293 310 { 294 311 await _context.Users.AddAsync(user); 295 312 await _context.SaveChangesAsync(); 313 return true; 296 314 } 297 315 } 316 return false; 298 317 } 299 318 300 319 public async Task<List<PharmacyHeadMedicine>> GetAllPHMedicines() 301 320 { 302 var list = await _context.PharmacyHeadMedicines.ToListAsync(); 321 var list = await _context.PharmacyHeadMedicines.Select(x => new PharmacyHeadMedicine 322 { 323 PheadId = x.PheadId, 324 Head = x.Head, 325 MedicineId = x.MedicineId, 326 Medicine = x.Medicine 327 } 328 ).ToListAsync(); 303 329 return list; 304 330 }
Note:
See TracChangeset
for help on using the changeset viewer.