Changeset c406ae5 for FarmatikoData
- Timestamp:
- 08/05/20 18:39:58 (4 years ago)
- Branches:
- master
- Children:
- 63d885e
- Parents:
- a6bbad1
- Location:
- FarmatikoData
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/HealthFacilityRepository.cs
ra6bbad1 rc406ae5 16 16 public void Add(HealthFacilities healthFacility) 17 17 { 18 _context.Add(healthFacility);19 _context.SaveChanges ();18 _context.HealthFacilities.Add(healthFacility); 19 _context.SaveChangesAsync(); 20 20 } 21 21 22 22 public IQueryable<HealthFacilities> GetAll() 23 23 { 24 return _context.HealthFacilities.OrderBy(x => x.Name); 24 return _context.HealthFacilities.Take(50).Select(x => new HealthFacilities 25 { 26 Name = x.Name, 27 Municipality = x.Municipality, 28 Address = x.Address, 29 Type = x.Type, 30 Email = x.Email, 31 Phone = x.Phone 32 }).OrderBy(x => x.Name); 33 } 34 35 public IQueryable<HealthFacilities> GetByName(string Name) 36 { 37 return _context.HealthFacilities.Where(x => x.Name.Equals(Name)); 25 38 } 26 39 27 40 public void Remove(HealthFacilities healthFacility) 28 41 { 29 var facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility.Name)); 30 _context.HealthFacilities.Remove((HealthFacilities)facility); 42 var facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility.Name)).FirstOrDefault(); 43 if (facility != null) 44 { 45 _context.HealthFacilities.Remove(facility); 46 _context.SaveChangesAsync(); 47 } 48 31 49 } 32 50 } -
FarmatikoData/FarmatikoRepo/HealthcareWorkerRepository.cs
ra6bbad1 rc406ae5 2 2 using FarmatikoData.Models; 3 3 using System.Linq; 4 using System.Threading.Tasks; 4 5 5 6 namespace FarmatikoData.FarmatikoRepo … … 23 24 public IQueryable<HealthcareWorkers> GetAll() 24 25 { 25 return _context.HealthcareWorkers.OrderBy(x => x.Name); 26 return _context.HealthcareWorkers.Take(50).Select(x => new HealthcareWorkers 27 { 28 Name = x.Name, 29 Branch = x.Branch, 30 Facility = x.Facility, 31 Title = x.Title 32 }).OrderBy(x => x.Name); 26 33 } 27 34 28 35 public void Remove(HealthcareWorkers healthcareWorker) 29 36 { 30 var healthCareWorker = _context.HealthcareWorkers.Where(x => x.Name.Equals(healthcareWorker.Name)); 31 _context.HealthcareWorkers.Remove((HealthcareWorkers)healthCareWorker); 37 var healthCareWorker = _context.HealthcareWorkers.Where(x => x.Name.Equals(healthcareWorker.Name)).FirstOrDefault(); 38 if (healthCareWorker != null) 39 { 40 _context.HealthcareWorkers.Remove(healthCareWorker); 41 _context.SaveChangesAsync(); 42 } 43 32 44 } 33 45 } -
FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
ra6bbad1 rc406ae5 29 29 public IQueryable<MedicineList> GetAll() 30 30 { 31 return _context.MedicineLists.OrderBy(x => x.Medicine.Name); 31 return _context.MedicineLists.Take(50).Select(x => new MedicineList 32 { 33 Medicine = x.Medicine, 34 HasMedicine = x.HasMedicine 35 }).OrderBy(x => x.Medicine.Name); 32 36 } 33 37 34 38 public ICollection<MedicineList> GetByManufacturer(string Manufacturer) 35 39 { 36 return (ICollection<MedicineList>)_context.MedicineLists 40 return (ICollection<MedicineList>)_context.MedicineLists.Take(50) 37 41 .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer)) 42 .Select(x => new MedicineList 43 { 44 Medicine = x.Medicine, 45 HasMedicine = x.HasMedicine 46 }) 38 47 .OrderBy(x => x.Medicine.Name) 39 48 .Cast<ICollection<MedicineList>>(); … … 41 50 public ICollection<MedicineList> GetByName(string Name) 42 51 { 43 return (ICollection<MedicineList>)_context.MedicineLists 52 return (ICollection<MedicineList>)_context.MedicineLists.Take(50) 44 53 .Where(x => x.Medicine.Name.Contains(Name)) 54 .Select(x => new MedicineList 55 { 56 Medicine = x.Medicine, 57 HasMedicine = x.HasMedicine 58 }) 45 59 .OrderBy(x => x.Medicine.Name) 46 60 .Cast<ICollection<MedicineList>>(); … … 49 63 public void Remove(MedicineList medicineList) 50 64 { 51 var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)); 52 _context.MedicineLists.Remove(list); 65 var list = _context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)).FirstOrDefault(); 66 if (list != null) 67 { 68 _context.MedicineLists.Remove(list); 69 _context.SaveChangesAsync(); 70 } 53 71 } 54 72 } -
FarmatikoData/FarmatikoRepo/MedicineRepository.cs
ra6bbad1 rc406ae5 21 21 public IQueryable<Medicine> GetAll() 22 22 { 23 return _context.Medicines.OrderBy(x => x.Name); 23 return _context.Medicines.Take(50).Select(x => new Medicine 24 { 25 Name = x.Name, 26 Strength = x.Strength, 27 Form = x.Form, 28 WayOfIssuing = x.WayOfIssuing, 29 Manufacturer = x.Manufacturer, 30 Price = x.Price, 31 Packaging = x.Packaging 32 }).OrderBy(x => x.Name); 24 33 } 25 34 26 35 public IQueryable<Medicine> GetByManufacturer(string Manufacturer) 27 36 { 28 return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer); 37 return _context.Medicines.Take(50).Where(x => x.Name.Contains(Manufacturer)) 38 .Select(x => new Medicine 39 { 40 Name = x.Name, 41 Strength = x.Strength, 42 Form = x.Form, 43 WayOfIssuing = x.WayOfIssuing, 44 Manufacturer = x.Manufacturer, 45 Price = x.Price, 46 Packaging = x.Packaging 47 }).OrderBy(x => x.Manufacturer); 29 48 } 30 49 31 50 public IQueryable<Medicine> GetByName(string Name) 32 51 { 33 return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name); 52 return _context.Medicines.Take(50).Where(medicine => medicine.Name.Contains(Name)) 53 .Select(x => new Medicine 54 { 55 Name = x.Name, 56 Strength = x.Strength, 57 Form = x.Form, 58 WayOfIssuing = x.WayOfIssuing, 59 Manufacturer = x.Manufacturer, 60 Price = x.Price, 61 Packaging = x.Packaging 62 }).OrderBy(x => x.Name); 34 63 } 35 64 36 public void Remove( stringmedicine)65 public void Remove(Medicine medicine) 37 66 { 38 Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine)); 39 _context.Medicines.Remove(med); 67 Medicine med = _context.Medicines.Where(medicine => medicine.Name.Equals(medicine.Name)).FirstOrDefault(); 68 if (med != null) 69 { 70 _context.Medicines.Remove(med); 71 _context.SaveChangesAsync(); 72 } 73 40 74 } 41 75 } -
FarmatikoData/FarmatikoRepo/PandemicRepository.cs
ra6bbad1 rc406ae5 22 22 public IQueryable<Pandemic> GetAll() 23 23 { 24 return _context.Pandemics.OrderBy(x => x.Name); 24 return _context.Pandemics.Select(x => new Pandemic 25 { 26 Name = x.Name, 27 TotalMK = x.TotalMK, 28 ActiveMK = x.ActiveMK, 29 DeathsMK = x.DeathsMK, 30 NewMK = x.NewMK, 31 TotalGlobal = x.TotalGlobal, 32 DeathsGlobal = x.DeathsGlobal, 33 ActiveGlobal = x.ActiveGlobal 34 }).OrderBy(x => x.Name); 25 35 } 26 36 27 37 public void Remove(Pandemic pandemic) 28 38 { 29 _context.Pandemics.Remove(pandemic); 30 _context.SaveChangesAsync(); 39 var Pandem = _context.Pandemics.Where(x => x.Name.Equals(pandemic.Name)).FirstOrDefault(); 40 if (Pandem != null) 41 { 42 _context.Pandemics.Remove(Pandem); 43 _context.SaveChangesAsync(); 44 } 31 45 } 32 46 } -
FarmatikoData/FarmatikoRepo/PharmacyHeadRepository.cs
ra6bbad1 rc406ae5 22 22 public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHeads) 23 23 { 24 return _context.PharmacyHeads 25 .Where(pharmacyHead => pharmacyHead.Name.Contains(NameOfPharmacyHeads)) 26 .OrderBy(x => x.Name); 24 return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Contains(NameOfPharmacyHeads)) 25 .Take(10).Select(x => new PharmacyHead 26 { 27 MedicineLists = x.MedicineLists, 28 PharmaciesList = x.PharmaciesList, 29 Email = x.Email, 30 Name = x.Name, 31 }).OrderBy(x => x.Name); 27 32 } 28 33 //Not needed 29 34 public IQueryable<PharmacyHead> GetPharmacyByName(string Name) 30 35 { 31 return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(Name)); 36 return _context.PharmacyHeads.Take(10) 37 .Where(pharmacyHead => pharmacyHead.Name.Equals(Name)) 38 .Select(x => new PharmacyHead 39 { 40 MedicineLists = x.MedicineLists, 41 PharmaciesList = x.PharmaciesList, 42 Email = x.Email, 43 Name = x.Name, 44 }).OrderBy(x => x.Name); 32 45 } 33 46 … … 35 48 { 36 49 37 IQueryable<MedicineList> Pharmacy = (IQueryable<MedicineList>)_context.PharmacyHeads.Where(x => x.Name.Equals(NameOfPharmacy)); 38 50 IQueryable<MedicineList> Pharmacy = (IQueryable<MedicineList>)_context.PharmacyHeads 51 .Take(50) 52 .Where(x => x.Name.Equals(NameOfPharmacy)) 53 .Select(x => new PharmacyHead 54 { 55 MedicineLists = x.MedicineLists 56 }).OrderBy(x => x.Name); 57 39 58 return Pharmacy; 40 59 } 41 60 42 public void Remove(PharmacyHead pharmacyHead , string Name)61 public void Remove(PharmacyHead pharmacyHead) 43 62 { 44 var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name)).FirstOrDefault(); 45 _context.PharmacyHeads.Remove(phead); 46 _context.SaveChangesAsync(); 63 var phead = _context.PharmacyHeads.Where(phead => phead.Name.Equals(pharmacyHead.Name)).FirstOrDefault(); 64 if (phead != null) 65 { 66 _context.PharmacyHeads.Remove(phead); 67 _context.SaveChangesAsync(); 68 } 47 69 } 48 70 } -
FarmatikoData/FarmatikoRepo/PharmacyRepository.cs
ra6bbad1 rc406ae5 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System; 3 4 using System.Collections.Generic; 4 5 using System.Linq; … … 18 19 { 19 20 _context.Pharmacies.Add(pharmacy); 20 _context.SaveChanges Async();21 _context.SaveChanges(); 21 22 } 22 23 //Just for users 23 24 public IQueryable<Pharmacy> GetAll() 24 25 { 25 return _context.Pharmacies.OrderBy(x => x.Name); 26 return _context.Pharmacies.Take(50) 27 .Select(x => new Pharmacy 28 { 29 Name = x.Name, 30 Location = x.Location, 31 Address = x.Address, 32 WorkAllTime = x.WorkAllTime 33 }).OrderBy(x => x.Name); 26 34 } 27 35 28 36 public ICollection<Pharmacy> GetPharmacies() 29 37 { 30 return (ICollection<Pharmacy>)_context.Pharmacies.Select(pharmacy => new 31 { 32 pharmacy.Name, 33 pharmacy.Address, 34 pharmacy.Location, 35 pharmacy.WorkAllTime 36 }).OrderBy(x => x.Name); 38 return (ICollection<Pharmacy>)_context.Pharmacies.Take(50) 39 .Select(pharmacy => new 40 { 41 pharmacy.Name, 42 pharmacy.Address, 43 pharmacy.Location, 44 pharmacy.WorkAllTime 45 }).OrderBy(x => x.Name); 37 46 } 38 47 39 48 public void Remove(Pharmacy pharmacy) 40 49 { 41 var pharma = _context.Pharmacies.Where(pharm => pharm.Name.Equals(pharmacy.Name)).Cast<Pharmacy>(); 42 _context.Pharmacies.Remove((Pharmacy)pharma); 43 _context.SaveChangesAsync(); 50 var pharma = _context.Pharmacies.Where(pharm => pharm.Name.Equals(pharmacy.Name)).FirstOrDefault(); 51 if (pharma != null) 52 { 53 _context.Pharmacies.Remove(pharmacy); 54 _context.SaveChangesAsync(); 55 } 44 56 } 45 57 46 public void UpdatePharmacy(Pharmacy pharmacy , string Name)58 public void UpdatePharmacy(Pharmacy pharmacy) 47 59 { 48 var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(Name)).Cast<Pharmacy>(); 49 _context.Pharmacies.Remove((Pharmacy)oldPharmacy); 50 _context.Pharmacies.Add(pharmacy); 51 _context.SaveChangesAsync(); 60 var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(pharmacy.Name)).FirstOrDefault(); 61 if (oldPharmacy != null) 62 { 63 _context.Pharmacies.Remove(oldPharmacy); 64 _context.Pharmacies.Add(pharmacy); 65 _context.SaveChangesAsync(); 66 } 67 throw new Exception("Pharmacy not found"); 52 68 } 53 69 } -
FarmatikoData/FarmatikoRepoInterfaces/IHealthFacilityRepository.cs
ra6bbad1 rc406ae5 9 9 void Add(HealthFacilities healthFacility); 10 10 void Remove(HealthFacilities healthFacility); 11 IQueryable<HealthFacilities> GetByName(string Name); 11 12 } 12 13 } -
FarmatikoData/FarmatikoRepoInterfaces/IMedicineRepository.cs
ra6bbad1 rc406ae5 9 9 IQueryable<Medicine> GetByName(string Name); 10 10 void Add(Medicine medicine); 11 void Remove( stringmedicine);11 void Remove(Medicine medicine); 12 12 IQueryable<Medicine> GetByManufacturer(string Manufacturer); 13 13 -
FarmatikoData/FarmatikoRepoInterfaces/IPharmacyHeadRepository.cs
ra6bbad1 rc406ae5 7 7 { 8 8 void Add(PharmacyHead pharmacyHead); 9 void Remove(PharmacyHead pharmacyHead , string Name);9 void Remove(PharmacyHead pharmacyHead); 10 10 IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead); 11 11 //Not actually needed -
FarmatikoData/FarmatikoRepoInterfaces/IPharmacyRepository.cs
ra6bbad1 rc406ae5 11 11 IQueryable<Pharmacy> GetAll(); 12 12 void Remove(Pharmacy pharmacy); 13 void UpdatePharmacy(Pharmacy pharmacy , string Name);13 void UpdatePharmacy(Pharmacy pharmacy); 14 14 15 15 } -
FarmatikoData/Models/HealthFacilities.cs
ra6bbad1 rc406ae5 22 22 public string Email { get; set; } 23 23 public string Phone { get; set; } 24 public HealthFacilities(string Name, string Municipality, string Address, string Type, string Email, string Phone) 25 { 26 this.Name = Name; 27 this.Municipality = Municipality; 28 this.Address = Address; 29 this.Type = Type; 30 this.Email = Email; 31 this.Phone = Phone; 32 } 24 33 } 25 34 } -
FarmatikoData/Models/HealthcareWorkers.cs
ra6bbad1 rc406ae5 18 18 public HealthFacilities Facility { get; set; } 19 19 public string Title { get; set; } 20 public HealthcareWorkers(string Name, string Branch, HealthFacilities Facility, string Title) 21 { 22 this.Name = Name; 23 this.Branch = Branch; 24 this.Facility = Facility; 25 this.Title = Title; 26 } 20 27 } 21 28 } -
FarmatikoData/Models/Medicine.cs
ra6bbad1 rc406ae5 13 13 public float Price { get; set; } 14 14 public string Packaging { get; set; } 15 public Medicine(string Name, string Strength, string Form, string WayOfIssuing, string Manufacturer, float Price, string Packaging) 16 { 17 this.Name = Name; 18 this.Strength = Strength; 19 this.Form = Form; 20 this.WayOfIssuing = WayOfIssuing; 21 this.Manufacturer = Manufacturer; 22 this.Price = Price; 23 this.Packaging = Packaging; 24 } 15 25 16 26 } -
FarmatikoData/Models/MedicineList.cs
ra6bbad1 rc406ae5 8 8 public class MedicineList : BaseEntity 9 9 { 10 public MedicineList() 11 { 12 } 10 13 public Medicine Medicine { get; set; } 11 14 public bool HasMedicine { get; set; } 15 public MedicineList(Medicine Medicine, bool HasMedicine) 16 { 17 this.Medicine = Medicine; 18 this.HasMedicine = HasMedicine; 19 } 12 20 /*public ICollection<MedicineList> MedicinesList { get; set; } 13 21 public MedicineList() -
FarmatikoData/Models/Pharmacy.cs
ra6bbad1 rc406ae5 14 14 public string Address { get; set; } 15 15 public bool WorkAllTime { get; set; } 16 public Pharmacy(string Name, string Location, string Address, bool WorkAllTime) 17 { 18 this.Name = Name; 19 this.Location = Location; 20 this.Address = Address; 21 this.WorkAllTime = WorkAllTime; 22 } 16 23 } 17 24 }
Note:
See TracChangeset
for help on using the changeset viewer.