Changes in / [ee137aa:63d885e]
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/Controllers/HealthFacilitiesController.cs
ree137aa r63d885e 26 26 } 27 27 [HttpGet] 28 public IQueryable<HealthFacilities> Get()28 public Task<IQueryable<HealthFacilities>> Get() 29 29 { 30 30 return _healthFacilitiesService.GetAll(); -
Farmatiko/Controllers/HealthcareWorkerController.cs
ree137aa r63d885e 1 1 using System.Linq; 2 using System.Threading.Tasks; 2 3 using FarmatikoData.Models; 3 4 using FarmatikoServices.FarmatikoServiceInterfaces; … … 17 18 18 19 [HttpGet] 19 public IQueryable<HealthcareWorkers> Get()20 public Task<IQueryable<HealthcareWorkers>> Get() 20 21 { 21 22 return _healthcareWorkerService.GetAll(); -
Farmatiko/Controllers/MedicineController.cs
ree137aa r63d885e 1 1 using System.Linq; 2 using System.Threading.Tasks; 2 3 using FarmatikoData.Models; 3 4 using FarmatikoServices.FarmatikoServiceInterfaces; … … 16 17 } 17 18 [HttpGet] 18 public IQueryable<Medicine> Get()19 public Task<IQueryable<Medicine>> Get() 19 20 { 20 21 return _medicineService.GetAll(); -
Farmatiko/Controllers/MedicineListController.cs
ree137aa r63d885e 1 1 using System.Collections.Generic; 2 2 using System.Linq; 3 using System.Threading.Tasks; 3 4 using FarmatikoData.Models; 4 5 using FarmatikoServices.FarmatikoServiceInterfaces; … … 17 18 } 18 19 [HttpGet] 19 public IQueryable<MedicineList> Get()20 public Task<IQueryable<MedicineList>> Get() 20 21 { 21 22 return _medicineListService.GetAll(); 22 23 } 23 24 [HttpGet] 24 public ICollection<MedicineList> GetByName(string Name)25 public Task<ICollection<MedicineList>> GetByName(string Name) 25 26 { 26 27 return _medicineListService.GetByName(Name); 27 28 } 28 29 [HttpGet] 29 public ICollection<MedicineList> GetByManufacturer(string Manufacturer)30 public Task<ICollection<MedicineList>> GetByManufacturer(string Manufacturer) 30 31 { 31 32 return _medicineListService.GetByManufacturer(Manufacturer); -
Farmatiko/Controllers/PandemicController.cs
ree137aa r63d885e 1 1 using System.Linq; 2 using System.Threading.Tasks; 2 3 using FarmatikoData.Models; 3 4 using FarmatikoServices.FarmatikoServiceInterfaces; … … 16 17 } 17 18 [HttpGet] 18 public IQueryable<Pandemic> Get()19 public Task<IQueryable<Pandemic>> Get() 19 20 { 20 21 return _pandemicService.GetAll(); -
Farmatiko/Controllers/PharmacyController.cs
ree137aa r63d885e 1 1 using System.Collections.Generic; 2 2 using System.Linq; 3 using System.Threading.Tasks; 3 4 using FarmatikoData.Models; 4 5 using FarmatikoServices.FarmatikoServiceInterfaces; … … 17 18 } 18 19 [HttpGet] 19 public IQueryable<Pharmacy> Get()20 public Task<IQueryable<Pharmacy>> Get() 20 21 { 21 22 return _pharmacyService.GetAll(); 22 23 } 23 24 [HttpGet] 24 public ICollection<Pharmacy> GetPharmacies()25 public Task<ICollection<Pharmacy>> GetPharmacies() 25 26 { 26 27 return _pharmacyService.GetPharmacies(); 27 28 } 28 29 [HttpPost] 29 public void UpdatePharmacy(Pharmacy pharmacy , string Name)30 public void UpdatePharmacy(Pharmacy pharmacy) 30 31 { 31 _pharmacyService.UpdatePharmacy(pharmacy ,Name);32 _pharmacyService.UpdatePharmacy(pharmacy); 32 33 } 33 34 [HttpPost] -
Farmatiko/Controllers/PharmacyHeadController.cs
ree137aa r63d885e 36 36 } 37 37 [HttpPost] 38 public void Remove(PharmacyHead pharmacyHead , string Name)38 public void Remove(PharmacyHead pharmacyHead) 39 39 { 40 _pharmacyHeadRepository.Remove(pharmacyHead , Name);40 _pharmacyHeadRepository.Remove(pharmacyHead); 41 41 } 42 42 } -
Farmatiko/Startup.cs
ree137aa r63d885e 12 12 using FarmatikoServices.FarmatikoServiceInterfaces; 13 13 using FarmatikoServices.Services; 14 using Microsoft.Extensions.Logging; 14 15 15 16 namespace Farmatiko … … 69 70 70 71 services.AddTransient<IProcessJSONService, ProcessJSONService>(); 72 73 services.AddTransient<ILogger, Logger<ProcessJSONService>>(); 71 74 } 72 75 -
FarmatikoData/FarmatikoRepo/HealthFacilityRepository.cs
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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
ree137aa r63d885e 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 } -
FarmatikoServices/FarmatikoServiceInterfaces/IHealthFacilityService.cs
ree137aa r63d885e 1 1 using FarmatikoData.Models; 2 2 using System.Linq; 3 using System.Threading.Tasks; 3 4 4 5 namespace FarmatikoData … … 6 7 public interface IHealthFacilityService 7 8 { 8 IQueryable<HealthFacilities> GetAll();9 Task<IQueryable<HealthFacilities>> GetAll(); 9 10 void Add(HealthFacilities healthFacility); 10 11 void Remove(HealthFacilities healthFacility); -
FarmatikoServices/FarmatikoServiceInterfaces/IHealthcareWorkerService.cs
ree137aa r63d885e 1 1 using FarmatikoData.Models; 2 2 using System.Linq; 3 using System.Threading.Tasks; 3 4 4 5 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 6 7 public interface IHealthcareWorkerService 7 8 { 8 IQueryable<HealthcareWorkers> GetAll();9 Task<IQueryable<HealthcareWorkers>> GetAll(); 9 10 void Add(HealthcareWorkers healthcareWorker); 10 11 void Remove(HealthcareWorkers healthcareWorker); -
FarmatikoServices/FarmatikoServiceInterfaces/IMedicineListService.cs
ree137aa r63d885e 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Threading.Tasks; 4 5 5 6 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 7 8 public interface IMedicineListService 8 9 { 9 IQueryable<MedicineList> GetAll();10 Task<IQueryable<MedicineList>> GetAll(); 10 11 //SetHasMedicine(MedicineList medicineList, bool HasMedicine); 11 ICollection<MedicineList> GetByName(string Name);12 ICollection<MedicineList> GetByManufacturer(string Manufacturer);12 Task<ICollection<MedicineList>> GetByName(string Name); 13 Task<ICollection<MedicineList>> GetByManufacturer(string Manufacturer); 13 14 void Add(MedicineList medicineList); 14 15 void Remove(MedicineList medicineList); -
FarmatikoServices/FarmatikoServiceInterfaces/IMedicineService.cs
ree137aa r63d885e 1 1 using FarmatikoData.Models; 2 2 using System.Linq; 3 using System.Threading.Tasks; 3 4 4 5 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 6 7 public interface IMedicineService 7 8 { 8 IQueryable<Medicine> GetAll();9 Task<IQueryable<Medicine>> GetAll(); 9 10 void Add(Medicine medicine); 10 void Remove( stringMedicine);11 IQueryable<Medicine> GetByName(string Name);12 IQueryable<Medicine> GetByManufacturer(string Manufacturer);11 void Remove(Medicine Medicine); 12 Task<IQueryable<Medicine>> GetByName(string Name); 13 Task<IQueryable<Medicine>> GetByManufacturer(string Manufacturer); 13 14 } 14 15 } -
FarmatikoServices/FarmatikoServiceInterfaces/IPandemicService.cs
ree137aa r63d885e 1 1 using FarmatikoData.Models; 2 2 using System.Linq; 3 using System.Threading.Tasks; 3 4 4 5 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 7 8 { 8 9 void Add(Pandemic pandemic); 9 IQueryable<Pandemic> GetAll();10 Task<IQueryable<Pandemic>> GetAll(); 10 11 void Remove(Pandemic pandemic); 11 12 } -
FarmatikoServices/FarmatikoServiceInterfaces/IPharmacyHeadService.cs
ree137aa r63d885e 1 1 using FarmatikoData.Models; 2 2 using System.Linq; 3 using System.Threading.Tasks; 3 4 4 5 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 7 8 { 8 9 void Add(PharmacyHead pharmacyHead); 9 void Remove(PharmacyHead pharmacyHead , string Name);10 IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead);10 void Remove(PharmacyHead pharmacyHead); 11 Task<IQueryable<PharmacyHead>> GetAllPharmacies(string NameOfPharmacyHead); 11 12 //Not actually needed 12 IQueryable<PharmacyHead> GetPharmacyByName(string Name);13 IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy);13 Task<IQueryable<PharmacyHead>> GetPharmacyByName(string Name); 14 Task<IQueryable<MedicineList>> GetPharmacyMedicines(string NameOfPharmacy); 14 15 } 15 16 } -
FarmatikoServices/FarmatikoServiceInterfaces/IPharmacyService.cs
ree137aa r63d885e 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Threading.Tasks; 4 5 5 6 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 8 9 { 9 10 void Add(Pharmacy pharmacy); 10 ICollection<Pharmacy> GetPharmacies();11 IQueryable<Pharmacy> GetAll();11 Task<ICollection<Pharmacy>> GetPharmacies(); 12 Task<IQueryable<Pharmacy>> GetAll(); 12 13 void Remove(Pharmacy pharmacy); 13 void UpdatePharmacy(Pharmacy pharmacy , string Name);14 void UpdatePharmacy(Pharmacy pharmacy); 14 15 } 15 16 } -
FarmatikoServices/FarmatikoServiceInterfaces/IProcessJSONService.cs
ree137aa r63d885e 3 3 using System.Collections.Generic; 4 4 using System.Text; 5 using System.Threading.Tasks; 5 6 6 7 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 8 9 public interface IProcessJSONService 9 10 { 10 List<HealthFacilities> GetProcessedHealthFacilitiesFromJSON(); 11 Task<HashSet<HealthFacilities>> GetProcessedHealthFacilitiesFromJSON(); 12 Task<HashSet<Pandemic>> GetProcessedPandemicsFromJSONApi(); 13 Task<HashSet<HealthcareWorkers>> GetProcessedHealthcareWorkersFromJSON(); 14 Task<HashSet<Medicine>> GetProcessedMedicinesFromJSON(); 11 15 } 12 16 } -
FarmatikoServices/Services/HealthFacilityService.cs
ree137aa r63d885e 4 4 using System; 5 5 using System.Linq; 6 using System.Threading.Tasks; 6 7 7 8 namespace FarmatikoServices … … 16 17 } 17 18 18 public void Add(HealthFacilities healthFacility)19 public async void Add(HealthFacilities healthFacility) 19 20 { 20 try 21 { 22 if (healthFacility != null) 23 _healthFacilityRepository.Add(healthFacility); 24 } 25 catch (Exception e) 26 { 27 e = new Exception("Can't Add health facility is null"); 28 throw e; 29 } 21 if (healthFacility != null) 22 await Task.Run(() => _healthFacilityRepository.Add(healthFacility)); 23 else throw new Exception("Can't add, health facility is null"); 30 24 } 31 25 32 public IQueryable<HealthFacilities> GetAll()26 public async Task<IQueryable<HealthFacilities>> GetAll() 33 27 { 34 return _healthFacilityRepository.GetAll();28 return await Task.Run(() => _healthFacilityRepository.GetAll()); 35 29 } 36 30 37 public void Remove(HealthFacilities healthFacility)31 public async void Remove(HealthFacilities healthFacility) 38 32 { 39 try 40 { 41 if (healthFacility != null) 42 _healthFacilityRepository.Remove(healthFacility); 43 } 44 catch(Exception e) 45 { 46 e = new Exception("Can't Remove health facility is null"); 47 throw e; 48 } 33 if (healthFacility != null) 34 await Task.Run(() => _healthFacilityRepository.Remove(healthFacility)); 35 else throw new Exception("Can't Remove health facility is null"); 36 49 37 } 50 38 } -
FarmatikoServices/Services/HealthcareWorkerService.cs
ree137aa r63d885e 4 4 using System; 5 5 using System.Linq; 6 using System.Threading.Tasks; 6 7 7 8 namespace FarmatikoServices.Services … … 14 15 _healthcareWorkerRepo = healthcareWorkerRepo; 15 16 } 16 public void Add(HealthcareWorkers healthcareWorker)17 public async void Add(HealthcareWorkers healthcareWorker) 17 18 { 18 try 19 { 20 if (healthcareWorker != null) 21 _healthcareWorkerRepo.Add(healthcareWorker); 22 } 23 catch (Exception e) 24 { 25 e = new Exception("Can't Add healthcare worker is null"); 26 throw e; 27 } 19 if (healthcareWorker != null) 20 await Task.Run(() => _healthcareWorkerRepo.Add(healthcareWorker)); 21 else throw new Exception("Can't add, healthcare worker is null"); 28 22 } 29 23 30 public IQueryable<HealthcareWorkers> GetAll()24 public async Task<IQueryable<HealthcareWorkers>> GetAll() 31 25 { 32 return _healthcareWorkerRepo.GetAll(); 26 var healthCareWorkers = await Task.Run(() => _healthcareWorkerRepo.GetAll()); 27 if (healthCareWorkers != null) 28 return healthCareWorkers; 29 return null; 33 30 } 34 31 35 public void Remove(HealthcareWorkers healthcareWorker)32 public async void Remove(HealthcareWorkers healthcareWorker) 36 33 { 37 try 38 { 39 if (healthcareWorker != null) 40 _healthcareWorkerRepo.Remove(healthcareWorker); 41 } 42 catch (Exception e) 43 { 44 e = new Exception("Can't Remove healthcare worker is null"); 45 throw e; 46 } 34 if (healthcareWorker != null) 35 await Task.Run(() => _healthcareWorkerRepo.Remove(healthcareWorker)); 36 else throw new Exception("Can't Remove healthcare worker is null"); 47 37 } 48 38 } -
FarmatikoServices/Services/MedicineListService.cs
ree137aa r63d885e 5 5 using System.Collections.Generic; 6 6 using System.Linq; 7 using System.Threading.Tasks; 7 8 8 9 namespace FarmatikoServices.Services … … 16 17 } 17 18 18 public void Add(MedicineList medicineList)19 public async void Add(MedicineList medicineList) 19 20 { 20 try 21 { 22 if (medicineList != null) 23 _medicineListRepository.Add(medicineList); 24 } 25 catch (Exception e) 26 { 27 e = new Exception("Can't add the medicine list is null."); 28 throw e; 29 } 21 if (medicineList != null) 22 await Task.Run(() => _medicineListRepository.Add(medicineList)); 23 else throw new Exception("Can't add, the medicine list is null."); 30 24 } 31 25 32 public IQueryable<MedicineList> GetAll()26 public async Task<IQueryable<MedicineList>> GetAll() 33 27 { 34 return _medicineListRepository.GetAll();28 return await Task.Run(() => _medicineListRepository.GetAll()); 35 29 } 36 30 37 public ICollection<MedicineList> GetByManufacturer(string Manufacturer)31 public async Task<ICollection<MedicineList>> GetByManufacturer(string Manufacturer) 38 32 { 39 try 40 { 41 if (Manufacturer != null) 42 { 43 44 return _medicineListRepository.GetByManufacturer(Manufacturer); 45 } 46 } 47 catch (Exception e) 48 { 49 e = new Exception("Can't get name of manufacturer is null"); 50 throw e; 51 } 52 return null; 33 if (Manufacturer != null) 34 return await Task.Run(() => _medicineListRepository.GetByManufacturer(Manufacturer)); 35 else throw new Exception("Can't get, name of manufacturer is null"); 53 36 } 54 37 55 public ICollection<MedicineList> GetByName(string Name)38 public async Task<ICollection<MedicineList>> GetByName(string Name) 56 39 { 57 try 58 { 59 if (Name != null) 60 { 61 return _medicineListRepository.GetByName(Name); 62 } 63 } 64 catch (Exception e) 65 { 66 e = new Exception("Can't get name is null"); 67 throw e; 68 } 69 return null; 40 if (Name != null) 41 return await Task.Run(() => _medicineListRepository.GetByName(Name)); 42 else throw new Exception("Can't get, name is null"); 70 43 } 71 44 72 public void Remove(MedicineList medicineList)45 public async void Remove(MedicineList medicineList) 73 46 { 74 try 75 { 76 if (medicineList != null) 77 _medicineListRepository.Remove(medicineList); 78 } 79 catch (Exception e) 80 { 81 e = new Exception("Can't remove the medicine list is null."); 82 throw e; 83 } 47 if (medicineList != null) 48 await Task.Run(() => _medicineListRepository.Remove(medicineList)); 49 else throw new Exception("Can't remove, the medicine list is null."); 84 50 } 85 51 } -
FarmatikoServices/Services/MedicineService.cs
ree137aa r63d885e 5 5 using System.Collections.Generic; 6 6 using System.Linq; 7 using System.Threading.Tasks; 7 8 8 9 namespace FarmatikoServices.Services … … 16 17 } 17 18 18 public void Add(Medicine medicine)19 public async void Add(Medicine medicine) 19 20 { 20 try 21 { 22 if (medicine != null) 23 _medicineRepository.Add(medicine); 24 } 25 catch (Exception e) 26 { 27 e = new Exception("Can't Add medicine is null"); 28 throw e; 29 } 21 if (medicine != null) 22 await Task.Run(() => _medicineRepository.Add(medicine)); 23 else throw new Exception("Can't Add medicine is null"); 30 24 } 31 25 32 public IQueryable<Medicine> GetAll()26 public async Task<IQueryable<Medicine>> GetAll() 33 27 { 34 return _medicineRepository.GetAll();28 return await Task.Run(() => _medicineRepository.GetAll()); 35 29 } 36 30 37 public IQueryable<Medicine> GetByManufacturer(string Manufacturer)31 public async Task<IQueryable<Medicine>> GetByManufacturer(string Manufacturer) 38 32 { 39 try 40 { 41 if (Manufacturer != null) 42 return _medicineRepository.GetByManufacturer(Manufacturer); 43 } 44 catch (Exception e) 45 { 46 e = new Exception("Can't get, name of manufacturer is null"); 47 throw e; 48 } 49 50 return null; 33 if (Manufacturer != null) 34 return await Task.Run(() => _medicineRepository.GetByManufacturer(Manufacturer)); 35 else throw new Exception("Can't get, name of manufacturer is null"); 51 36 } 52 37 53 public IQueryable<Medicine> GetByName(string Name)38 public async Task<IQueryable<Medicine>> GetByName(string Name) 54 39 { 55 try 56 { 57 if (Name != null) 58 return _medicineRepository.GetByName(Name); 59 } 60 catch (Exception e) 61 { 62 e = new Exception("Can't get, name is null"); 63 } 64 65 return null; 40 if (Name != null) 41 return await Task.Run(() => _medicineRepository.GetByName(Name)); 42 else throw new Exception("Can't get, name is null"); 66 43 } 67 44 68 public void Remove(stringMedicine)45 public async void Remove(Medicine Medicine) 69 46 { 70 try 71 { 72 if (Medicine != null) 73 _medicineRepository.Remove(Medicine); 74 } 75 catch (Exception e) 76 { 77 e = new Exception("Can't Add medicine is null"); 78 throw e; 79 } 47 if (Medicine != null) 48 await Task.Run(() => _medicineRepository.Remove(Medicine)); 49 else throw new Exception("Can't Add medicine is null"); 80 50 } 81 51 } -
FarmatikoServices/Services/PandemicService.cs
ree137aa r63d885e 4 4 using System; 5 5 using System.Linq; 6 using System.Threading.Tasks; 6 7 7 8 namespace FarmatikoServices.Services … … 15 16 } 16 17 17 public void Add(Pandemic pandemic)18 public async void Add(Pandemic pandemic) 18 19 { 19 try 20 { 21 if (pandemic != null) 22 { 23 _pandemicRepository.Add(pandemic); 24 } 25 } 26 catch (Exception e) 27 { 28 e = new Exception("Can't add pandemic is null."); 29 throw e; 30 } 20 if (pandemic != null) 21 await Task.Run(() => _pandemicRepository.Add(pandemic)); 22 else throw new Exception("Can't add pandemic is null."); 31 23 } 32 24 33 public IQueryable<Pandemic> GetAll()25 public async Task<IQueryable<Pandemic>> GetAll() 34 26 { 35 return _pandemicRepository.GetAll();27 return await Task.Run(() => _pandemicRepository.GetAll()); 36 28 } 37 29 38 public void Remove(Pandemic pandemic)30 public async void Remove(Pandemic pandemic) 39 31 { 40 try 41 { 42 if (pandemic != null) 43 _pandemicRepository.Remove(pandemic); 44 } 45 catch (Exception e) 46 { 47 e = new Exception("Can't remove, pandemic is null."); 48 } 32 if (pandemic != null) 33 await Task.Run(() => _pandemicRepository.Remove(pandemic)); 34 else throw new Exception("Can't remove, pandemic is null."); 49 35 } 50 36 } -
FarmatikoServices/Services/PharmacyHeadService.cs
ree137aa r63d885e 4 4 using System; 5 5 using System.Linq; 6 using System.Threading.Tasks; 6 7 7 8 namespace FarmatikoServices.Services … … 15 16 } 16 17 17 public void Add(PharmacyHead pharmacyHead)18 public async void Add(PharmacyHead pharmacyHead) 18 19 { 19 try 20 { 21 if (pharmacyHead != null) 22 { 23 _pharmacyHeadRepository.Add(pharmacyHead); 24 } 25 } 26 catch (Exception e) 27 { 28 e = new Exception("Can't add, pharmacy head is null."); 29 } 30 20 if (pharmacyHead != null) 21 await Task.Run(() => _pharmacyHeadRepository.Add(pharmacyHead)); 22 else throw new Exception("Can't add, pharmacy head is null."); 31 23 } 32 24 33 public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead)25 public async Task<IQueryable<PharmacyHead>> GetAllPharmacies(string NameOfPharmacyHead) 34 26 { 35 27 if (NameOfPharmacyHead != null) 36 28 { 37 IQueryable<PharmacyHead> Pharmacy = _pharmacyHeadRepository.GetAllPharmacies(NameOfPharmacyHead);38 if ( Pharmacy!= null)39 return Pharmacy;29 IQueryable<PharmacyHead> pharmacies = await Task.Run(() => _pharmacyHeadRepository.GetAllPharmacies(NameOfPharmacyHead)); 30 if (pharmacies != null) 31 return pharmacies; 40 32 } 41 33 return null; 42 34 } 43 35 44 public IQueryable<PharmacyHead> GetPharmacyByName(string Name)36 public async Task<IQueryable<PharmacyHead>> GetPharmacyByName(string Name) 45 37 { 46 38 if (Name != null) 47 39 { 48 IQueryable<PharmacyHead> PharmacyHead = _pharmacyHeadRepository.GetPharmacyByName(Name);40 IQueryable<PharmacyHead> PharmacyHead = await Task.Run(() => _pharmacyHeadRepository.GetPharmacyByName(Name)); 49 41 if (PharmacyHead != null) 50 42 return PharmacyHead; … … 53 45 } 54 46 55 public IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy)47 public async Task<IQueryable<MedicineList>> GetPharmacyMedicines(string NameOfPharmacy) 56 48 { 57 49 if (NameOfPharmacy != null) 58 50 { 59 IQueryable<MedicineList> Medicines = _pharmacyHeadRepository.GetPharmacyMedicines(NameOfPharmacy);51 IQueryable<MedicineList> Medicines = await Task.Run(() => _pharmacyHeadRepository.GetPharmacyMedicines(NameOfPharmacy)); 60 52 if (Medicines != null) 61 53 return Medicines; … … 64 56 } 65 57 66 public void Remove(PharmacyHead pharmacyHead, string Name)58 public async void Remove(PharmacyHead pharmacyHead) 67 59 { 68 try 69 { 70 if (Name != null) 71 { 72 _pharmacyHeadRepository.Remove(pharmacyHead, Name); 73 } 74 } 75 catch (Exception e) 76 { 77 e = new Exception("Can't remove, name of pharmacy head is null."); 78 } 79 60 if (pharmacyHead != null) 61 await Task.Run(() => _pharmacyHeadRepository.Remove(pharmacyHead)); 62 else throw new Exception("Can't remove, name of pharmacy head is null."); 80 63 } 81 64 } -
FarmatikoServices/Services/PharmacyService.cs
ree137aa r63d885e 5 5 using System.Collections.Generic; 6 6 using System.Linq; 7 using System.Threading.Tasks; 7 8 8 9 namespace FarmatikoServices.Services … … 15 16 _pharmacyRepository = pharmacyRepository; 16 17 } 17 public void Add(Pharmacy pharmacy)18 public async void Add(Pharmacy pharmacy) 18 19 { 19 try 20 { 21 if (pharmacy != null) 22 { 23 _pharmacyRepository.Add(pharmacy); 24 } 25 } 26 catch (Exception e) 27 { 28 e = new Exception("Can't add, pharmacy has null value."); 29 throw e; 30 } 31 20 if (pharmacy != null) 21 await Task.Run(() => _pharmacyRepository.Add(pharmacy)); 22 else throw new Exception("Can't add, pharmacy has null value."); 32 23 } 33 24 34 public IQueryable<Pharmacy> GetAll()25 public async Task<IQueryable<Pharmacy>> GetAll() 35 26 { 36 return _pharmacyRepository.GetAll();27 return await Task.Run(() => _pharmacyRepository.GetAll()); 37 28 } 38 29 39 public ICollection<Pharmacy> GetPharmacies()30 public async Task<ICollection<Pharmacy>> GetPharmacies() 40 31 { 41 return _pharmacyRepository.GetPharmacies();32 return await Task.Run(() => _pharmacyRepository.GetPharmacies()); 42 33 } 43 34 44 public void Remove(Pharmacy pharmacy)35 public async void Remove(Pharmacy pharmacy) 45 36 { 46 try 47 { 48 if (pharmacy != null) 49 _pharmacyRepository.Remove(pharmacy); 50 } 51 catch (Exception e) 52 { 53 e = new Exception("Can't remove, pharmacy has null value."); 54 throw e; 55 } 37 if (pharmacy != null) 38 await Task.Run(() => _pharmacyRepository.Remove(pharmacy)); 39 else throw new Exception("Can't remove, pharmacy has null value."); 56 40 } 57 41 58 public void UpdatePharmacy(Pharmacy pharmacy, string Name)42 public async void UpdatePharmacy(Pharmacy pharmacy) 59 43 { 60 try 61 { 62 if (pharmacy != null && Name != null) 63 { 64 _pharmacyRepository.UpdatePharmacy(pharmacy, Name); 65 } 66 } 67 catch (Exception e) 68 { 69 e = new Exception("Can not update pharmacy, has null value."); 70 throw e; 71 } 72 44 if (pharmacy != null) 45 await Task.Run(() => _pharmacyRepository.UpdatePharmacy(pharmacy)); 46 else throw new Exception("Can not update pharmacy, has null value."); 73 47 } 74 48 } -
FarmatikoServices/Services/ProcessJSONService.cs
ree137aa r63d885e 10 10 using FarmatikoServices.FarmatikoServiceInterfaces; 11 11 using RestSharp; 12 using System.Threading.Tasks; 12 13 13 14 namespace FarmatikoServices.Services … … 15 16 public class ProcessJSONService : IProcessJSONService 16 17 { 17 //private IHealthFacilityRepository _healthFacilityRepository;18 private IHealthFacilityRepository _healthFacilityRepository; 18 19 private IPandemicRepository _pandemicRepository; 19 //private IHealthcareWorkerRepository _healthcareWorkerRepository;20 //private IMedicineRepository _medicineRepository;21 //private readonly ILogger _logger;22 public ProcessJSONService( /*IHealthFacilityRepository healthFacilityRepository, */IPandemicRepository pandemicRepository/*,23 IHealthcareWorkerRepository healthcareWorkerRepository, IMedicineRepository medicineRepository */)20 private IHealthcareWorkerRepository _healthcareWorkerRepository; 21 private IMedicineRepository _medicineRepository; 22 private readonly ILogger _logger; 23 public ProcessJSONService(IHealthFacilityRepository healthFacilityRepository, IPandemicRepository pandemicRepository, 24 IHealthcareWorkerRepository healthcareWorkerRepository, IMedicineRepository medicineRepository, ILogger logger) 24 25 { 25 //_logger = logger;26 //_healthFacilityRepository = healthFacilityRepository;26 _logger = logger; 27 _healthFacilityRepository = healthFacilityRepository; 27 28 _pandemicRepository = pandemicRepository; 28 //_healthcareWorkerRepository = healthcareWorkerRepository;29 //_medicineRepository = medicineRepository;29 _healthcareWorkerRepository = healthcareWorkerRepository; 30 _medicineRepository = medicineRepository; 30 31 } 31 32 public List<HealthFacilities> GetProcessedHealthFacilitiesFromJSON()32 33 public async Task<HashSet<HealthFacilities>> GetProcessedHealthFacilitiesFromJSON() 33 34 { 34 35 try 35 36 { 36 /*var client = new WebClient(); 37 var json = client.DownloadString(@"C:\Users\Miki\Desktop\ustanovi.json"); 37 HashSet<HealthFacilities> hashSet = new HashSet<HealthFacilities>(); 38 var client = new WebClient(); 39 var json = client.DownloadString(@"C:\Users\dslez\Desktop\ustanovi.json"); 38 40 39 41 var jsonResponse = JObject.Parse(json); 40 42 var records = JArray.Parse(jsonResponse.GetValue("records").ToString()); 41 43 42 foreach (var rec in records)44 foreach (var rec in records) 43 45 { 44 46 dynamic obj = JsonConvert.DeserializeObject(rec.ToString()); … … 49 51 var Phone = obj[11]; 50 52 var Type = obj[5]; 51 HealthFacilities healthFacility = new HealthFacilities( );52 healthFacility.Name = Name;53 HealthFacilities healthFacility = new HealthFacilities(Name, Municipality, Address, Type, Email, Phone); 54 /*healthFacility.Name = Name; 53 55 healthFacility.Municipality = Municipality; 54 56 healthFacility.Address = Address; 55 57 healthFacility.Email = Email; 56 58 healthFacility.Phone = Phone; 57 healthFacility.Type = Type; 58 _healthFacilityRepository.Add(healthFacility); 59 60 }*/ 59 healthFacility.Type = Type;*/ 60 //hashSet.Add(healthFacility); 61 await Task.Run(() => _healthFacilityRepository.Add(healthFacility)); 61 62 63 } 62 64 65 } 66 catch (Exception e) 67 { 68 _logger.LogInformation(e.Message); 69 throw new Exception("Cannot process health facilities from JSON."); 70 } 71 return null; 72 } 63 73 64 var client1 = new RestClient("https://api.covid19api.com/summary"); 65 var response = client1.Execute(new RestRequest()); 74 public async Task<HashSet<Pandemic>> GetProcessedPandemicsFromJSONApi() 75 { 76 try 77 { 78 var client = new RestClient("https://api.covid19api.com/summary"); 79 var response = client.Execute(new RestRequest()); 66 80 string original = response.Content; 67 81 var jsonResponsePandemic = JObject.Parse(original); … … 78 92 var NewMK = Int32.Parse(objP.GetValue("NewConfirmed").ToString()); 79 93 80 Pandemic pandemic = new Pandemic(); 81 pandemic.TotalGlobal = TotalConfirmed; 94 var Name = "Coronavirus"; 95 var ActiveMk = TotalMk - (TotalRecoveredMK + TotalDeathsMK); 96 var ActiveGlobal = TotalConfirmed - (TotalRecovered + TotalDeaths); 97 98 Pandemic pandemic = new Pandemic(Name, TotalMk, ActiveMk, TotalDeathsMK, NewMK, TotalConfirmed, TotalDeaths, ActiveGlobal); 99 /*pandemic.TotalGlobal = TotalConfirmed; 82 100 pandemic.ActiveGlobal = TotalConfirmed - (TotalRecovered + TotalDeaths); 83 101 pandemic.DeathsGlobal = TotalDeaths; … … 86 104 pandemic.DeathsMK = TotalDeathsMK; 87 105 pandemic.NewMK = NewMK; 88 pandemic.Name = "Coronavirus"; 89 _pandemicRepository.Add(pandemic); 106 pandemic.Name = "Coronavirus";*/ 107 await Task.Run(() => _pandemicRepository.Add(pandemic)); 108 } 109 catch (Exception e) 110 { 111 _logger.LogInformation(e.Message); 112 } 113 return null; 114 } 90 115 91 92 93 /*var jsonW = client.DownloadString(@"C:\Users\Miki\Desktop\rabotnici.json"); 116 public async Task<HashSet<HealthcareWorkers>> GetProcessedHealthcareWorkersFromJSON() 117 { 118 try 119 { 120 var client = new WebClient(); 121 var jsonW = client.DownloadString(@"C:\Users\dslez\Desktop\rabotnici.json"); 94 122 95 123 var jsonResponseW = JObject.Parse(jsonW); … … 101 129 var Name = obj[4]; 102 130 var Branch = obj[2]; 103 HealthFacilities facility = new HealthFacilities(); 104 facility.Name = obj[1]; 105 facility.Municipality = "WorkerFacilityMunicipality"; 106 facility.Address = "WorkerFacilityAddress"; 131 var FacilityName = obj[1]; 107 132 var Title = obj[3]; 108 HealthcareWorkers healthcareWorker = new HealthcareWorkers(); 109 healthcareWorker.Name = Name; 133 HealthFacilities facility = _healthFacilityRepository.GetByName(FacilityName); 134 HealthFacilities Facility = new HealthFacilities(facility.Name, facility.Municipality, facility.Address, 135 facility.Type, facility.Email, facility.Phone); 136 HealthcareWorkers healthcareWorker = new HealthcareWorkers(Name, Branch, Facility, Title); 137 /*Facility.Name = obj[1]; 138 Facility.Municipality = "WorkerFacilityMunicipality"; 139 Facility.Address = "WorkerFacilityAddress";*/ 140 /*healthcareWorker.Name = Name; 110 141 healthcareWorker.Branch = Branch; 111 healthcareWorker.Facility = facility;112 healthcareWorker.Title = Title; 113 _healthcareWorkerRepository.Add(healthcareWorker);142 healthcareWorker.Facility = Facility; 143 healthcareWorker.Title = Title;*/ 144 await Task.Run(() => _healthcareWorkerRepository.Add(healthcareWorker)); 114 145 } 146 } 147 catch (Exception e) 148 { 149 _logger.LogInformation(e.Message); 150 } 151 return null; 152 } 115 153 116 117 118 var jsonM = client.DownloadString(@"C:\Users\Miki\Desktop\lekovi.json"); 154 public async Task<HashSet<Medicine>> GetProcessedMedicinesFromJSON() 155 { 156 try 157 { 158 var client = new WebClient(); 159 var jsonM = client.DownloadString(@"C:\Users\dslez\Desktop\lekovi.json"); 119 160 120 161 var jsonResponseM = JObject.Parse(jsonM); … … 131 172 var Price = float.Parse(obj[17]); 132 173 var Packaging = obj[8]; 133 Medicine medicine = new Medicine( );134 medicine.Name = Name;174 Medicine medicine = new Medicine(Name, Strength, Form, WayOfIssuing, Manufacturer, Price, Packaging); 175 /*medicine.Name = Name; 135 176 medicine.Strength = Strength; 136 177 medicine.Form = Form; … … 138 179 medicine.Manufacturer = Manufacturer; 139 180 medicine.Price = Price; 140 medicine.Packaging = Packaging; 141 _medicineRepository.Add(medicine); 142 }*/ 143 144 181 medicine.Packaging = Packaging;*/ 182 await Task.Run(() => _medicineRepository.Add(medicine)); 183 } 145 184 } 146 185 catch (Exception e) 147 186 { 148 //_logger.LogError(e.Message); 149 Console.WriteLine(e.Message); 150 throw e; 151 return null; 187 _logger.LogInformation(e.Message); 152 188 } 153 189 return null; 154 190 } 155 156 191 } 157 192 }
Note:
See TracChangeset
for help on using the changeset viewer.