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