Changeset a55ef91 for FarmatikoData/FarmatikoRepo
- Timestamp:
- 07/31/20 10:15:02 (4 years ago)
- Branches:
- master
- Children:
- d8fafb8
- Parents:
- 4e72684
- Location:
- FarmatikoData/FarmatikoRepo
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/HealthFacilityRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 using System;3 2 using System.Linq; 4 using System.Collections.Generic;5 using System.Text;6 3 using FarmatikoData.Models; 7 using Microsoft.EntityFrameworkCore;8 4 9 5 namespace FarmatikoData.FarmatikoRepo … … 21 17 { 22 18 _context.Add(healthFacility); 23 _context.SaveChanges Async();19 _context.SaveChanges(); 24 20 } 25 21 26 public I Enumerable<HealthFacilities> GetAll()22 public IQueryable<HealthFacilities> GetAll() 27 23 { 28 return _context.HealthFacilities.OrderBy(x => x.Name) .ToList();24 return _context.HealthFacilities.OrderBy(x => x.Name); 29 25 } 30 26 27 public void Remove(HealthFacilities healthFacility) 28 { 29 var facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility.Name)); 30 _context.HealthFacilities.Remove((HealthFacilities)facility); 31 } 31 32 } 32 33 } -
FarmatikoData/FarmatikoRepo/HealthcareWorkerRepository.cs
r4e72684 ra55ef91 2 2 using FarmatikoData.Models; 3 3 using System.Linq; 4 using System.Collections.Generic;5 4 6 5 namespace FarmatikoData.FarmatikoRepo … … 18 17 public void Add(HealthcareWorkers HealthcareWorker) 19 18 { 20 _context. Add(HealthcareWorker);19 _context.HealthcareWorkers.Add(HealthcareWorker); 21 20 _context.SaveChangesAsync(); 22 21 } 23 22 24 public I Enumerable<HealthcareWorkers> GetAll()23 public IQueryable<HealthcareWorkers> GetAll() 25 24 { 26 25 return _context.HealthcareWorkers.OrderBy(x => x.Name); … … 29 28 public void Remove(HealthcareWorkers healthcareWorker) 30 29 { 31 _context.Remove(healthcareWorker); 30 var healthCareWorker = _context.HealthcareWorkers.Where(x => x.Name.Equals(healthcareWorker.Name)); 31 _context.HealthcareWorkers.Remove((HealthcareWorkers)healthCareWorker); 32 32 } 33 33 } -
FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using Microsoft.EntityFrameworkCore; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 17 18 _context.SaveChangesAsync(); 18 19 } 19 public MedicineList CheckMedicine(string Name)20 /*public MedicineList CheckMedicine(string Name) 20 21 { 21 22 return (MedicineList)_context.MedicineLists 22 23 .Where(medicineList => medicineList.Medicine.Name.Contains(Name)) 23 .OrderBy(x => x.Medicine.Name); 24 } 25 26 public IEnumerable<MedicineList> GetAll() 24 .OrderBy(x => x.Medicine.Name) 25 .Include(x => x.HasMedicine) 26 .Cast<MedicineList>(); 27 }*/ 28 29 public IQueryable<MedicineList> GetAll() 27 30 { 28 31 return _context.MedicineLists.OrderBy(x => x.Medicine.Name); … … 33 36 return (ICollection<MedicineList>)_context.MedicineLists 34 37 .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer)) 35 .OrderBy(x => x.Medicine.Name); 38 .OrderBy(x => x.Medicine.Name) 39 .Cast<ICollection<MedicineList>>(); 36 40 } 37 41 public ICollection<MedicineList> GetByName(string Name) … … 39 43 return (ICollection<MedicineList>)_context.MedicineLists 40 44 .Where(x => x.Medicine.Name.Contains(Name)) 41 .OrderBy(x => x.Medicine.Name); 45 .OrderBy(x => x.Medicine.Name) 46 .Cast<ICollection<MedicineList>>(); 42 47 } 43 48 44 49 public void Remove(MedicineList medicineList) 45 50 { 46 var list = (MedicineList)_context.MedicineLists.Where(x => x. Equals(medicineList));51 var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)); 47 52 _context.MedicineLists.Remove(list); 48 }49 50 public bool SetHasMedicine(MedicineList medicineList, bool HasMedicine)51 {52 MedicineList medicine = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Name.Equals(medicineList.Medicine.Name));53 54 if (medicine != null || medicineList != null)55 {56 if (HasMedicine == true)57 {58 medicine.HasMedicine = HasMedicine;59 _context.MedicineLists.Add(medicine);60 _context.SaveChangesAsync();61 return true;62 }63 else64 {65 medicine.HasMedicine = HasMedicine;66 _context.MedicineLists.Add(medicine);67 _context.SaveChangesAsync();68 return true;69 }70 }else71 {72 return false;73 }74 53 } 75 54 } -
FarmatikoData/FarmatikoRepo/MedicineRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System .Collections.Generic;3 using System; 4 4 using System.Linq; 5 5 … … 15 15 public void Add(Medicine Medicine) 16 16 { 17 _context. Add(Medicine);17 _context.Medicines.Add(Medicine); 18 18 _context.SaveChangesAsync(); 19 19 } 20 20 21 public I Enumerable<Medicine> GetAll()21 public IQueryable<Medicine> GetAll() 22 22 { 23 23 return _context.Medicines.OrderBy(x => x.Name); 24 24 } 25 25 26 public I Enumerable<Medicine> GetByManufacturer(string Manufacturer)26 public IQueryable<Medicine> GetByManufacturer(string Manufacturer) 27 27 { 28 28 return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer); 29 29 } 30 30 31 public I Enumerable<Medicine> GetByName(string Name)31 public IQueryable<Medicine> GetByName(string Name) 32 32 { 33 return _context.Medicines.Where(medicine => medicine.Name ==Name);33 return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name); 34 34 } 35 35 -
FarmatikoData/FarmatikoRepo/PandemicRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore;4 using System;5 using System.Collections.Generic;6 3 using System.Linq; 7 using System.Text;8 4 9 5 namespace FarmatikoData.FarmatikoRepo … … 24 20 } 25 21 26 public I Enumerable<Pandemic> GetAll()22 public IQueryable<Pandemic> GetAll() 27 23 { 28 return _context.Pandemics ;24 return _context.Pandemics.OrderBy(x => x.Name); 29 25 } 30 26 -
FarmatikoData/FarmatikoRepo/PharmacyHeadRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System;4 using System.Collections.Generic;5 3 using System.Linq; 6 using System.Text;7 4 8 5 namespace FarmatikoData.FarmatikoRepo … … 45 42 public void Remove(PharmacyHead pharmacyHead, string Name) 46 43 { 47 var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name)) ;44 var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name)).FirstOrDefault(); 48 45 _context.PharmacyHeads.Remove(phead); 49 46 _context.SaveChangesAsync(); -
FarmatikoData/FarmatikoRepo/PharmacyRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System;4 3 using System.Collections.Generic; 5 4 using System.Linq; 6 using System.Text;7 5 8 6 namespace FarmatikoData.FarmatikoRepo … … 23 21 } 24 22 //Just for users 25 public I Enumerable<Pharmacy> GetAll()23 public IQueryable<Pharmacy> GetAll() 26 24 { 27 25 return _context.Pharmacies.OrderBy(x => x.Name); … … 36 34 pharmacy.Location, 37 35 pharmacy.WorkAllTime 38 }) ;36 }).OrderBy(x => x.Name); 39 37 } 40 38 41 39 public void Remove(Pharmacy pharmacy) 42 40 { 43 var pharma = _context.Pharmacies.Where(pharm => pharm. Equals(pharmacy));41 var pharma = _context.Pharmacies.Where(pharm => pharm.Name.Equals(pharmacy.Name)).Cast<Pharmacy>(); 44 42 _context.Pharmacies.Remove((Pharmacy)pharma); 45 43 _context.SaveChangesAsync(); … … 48 46 public void UpdatePharmacy(Pharmacy pharmacy, string Name) 49 47 { 50 var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(Name)) ;48 var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(Name)).Cast<Pharmacy>(); 51 49 _context.Pharmacies.Remove((Pharmacy)oldPharmacy); 52 50 _context.Pharmacies.Add(pharmacy);
Note:
See TracChangeset
for help on using the changeset viewer.