Changeset 1454207
- Timestamp:
- 10/01/20 03:17:09 (4 years ago)
- Branches:
- master
- Children:
- 6f203af
- Parents:
- 5d02859
- Files:
-
- 11 added
- 28 deleted
- 12 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/admin/admin.component.ts
r5d02859 r1454207 123 123 this.dataService.updatePharmacyHead(req.PharmacyHead) 124 124 .subscribe(() => { 125 125 this.rejectRequest(req); 126 126 }, 127 127 (err: any) => console.log(err), -
Farmatiko/Controllers/FarmatikoController.cs
r5d02859 r1454207 20 20 [HttpGet] 21 21 [Route("/api/workers")] 22 public async Task<IQueryable<HealthcareWorker s>> GetWorkers()22 public async Task<IQueryable<HealthcareWorker>> GetWorkers() 23 23 { 24 return await _service.GetAllWorkers(); 24 var Workers = await _service.GetAllWorkers(); 25 return Workers; 25 26 } 26 27 [HttpGet] 27 28 [Route("/api/workers/search/{Query}")] 28 public async Task<IQueryable<HealthcareWorker s>> SearchWorkers(string Query)29 public async Task<IQueryable<HealthcareWorker>> SearchWorkers(string Query) 29 30 { 30 31 return await _service.SearchWorkers(Query); … … 32 33 [HttpGet] 33 34 [Route("/api/workers/{id}")] 34 public async Task<HealthcareWorker s> GetWorker(int Id)35 public async Task<HealthcareWorker> GetWorker(int Id) 35 36 { 36 37 return await _service.GetWorker(Id); … … 43 44 [HttpGet] 44 45 [Route("/api/facilities")] 45 public async Task<IQueryable<HealthFacilit ies>> GetFacilities()46 public async Task<IQueryable<HealthFacility>> GetFacilities() 46 47 { 47 48 return await _service.GetFacilities(); … … 49 50 [HttpGet] 50 51 [Route("/api/facilities/search/{Query}")] 51 public async Task<IQueryable<HealthFacilit ies>> SearchFacilities(string Query)52 public async Task<IQueryable<HealthFacility>> SearchFacilities(string Query) 52 53 { 53 54 return await _service.SearchFacilities(Query); … … 55 56 [HttpGet] 56 57 [Route("/api/facilities/{Id}")] 57 public async Task<HealthFacilit ies> GetFacility(int Id)58 public async Task<HealthFacility> GetFacility(int Id) 58 59 { 59 60 return await _service.GetFacility(Id); -
Farmatiko/Controllers/PharmacyHeadController.cs
r5d02859 r1454207 1 1 using System.Linq; 2 using System.Threading.Tasks; 2 3 using FarmatikoData.FarmatikoRepoInterfaces; 3 4 using FarmatikoData.Models; 5 using FarmatikoServices.FarmatikoServiceInterfaces; 4 6 using Microsoft.AspNetCore.Mvc; 5 7 … … 10 12 public class PharmacyHeadController : Controller 11 13 { 12 private readonly IP harmacyHeadRepository _pharmacyHeadRepository;13 public PharmacyHeadController(IP harmacyHeadRepository pharmacyHeadRepository)14 private readonly IPHService _PHService; 15 public PharmacyHeadController(IPHService PHService) 14 16 { 15 _ pharmacyHeadRepository = pharmacyHeadRepository;17 _PHService = PHService; 16 18 } 19 20 //GET 21 //Mi trebaat rutite 17 22 [HttpGet] 18 public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacy)23 public async Task<IQueryable<PharmacyHead>> GetPharmacyHeadInfo(string Token) 19 24 { 20 return _pharmacyHeadRepository.GetAllPharmacies(NameOfPharmacy);25 return await _PHService.GetPharmacyHeadInfo(Token); 21 26 } 22 [HttpGet] 23 public IQueryable<PharmacyHead> GetPharmacyByName(string Name) 27 //POST 28 [HttpPost] 29 public async Task<int> Login(PharmacyHead pharmacyHead) 24 30 { 25 return _pharmacyHeadRepository.GetPharmacyByName(Name); 26 } 27 [HttpGet] 28 public IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy) 29 { 30 return _pharmacyHeadRepository.GetPharmacyMedicines(NameOfPharmacy); 31 return await _PHService.Login(pharmacyHead); 31 32 } 32 33 [HttpPost] 33 public void Add(PharmacyHead pharmacyHead)34 public async Task UpdatePharmacyHead(PharmacyHead pharmacyHead) 34 35 { 35 _pharmacyHeadRepository.Add(pharmacyHead);36 await _PHService.UpdatePharmacyHead(pharmacyHead); 36 37 } 37 38 [HttpPost] 38 public void Remove(PharmacyHead pharmacyHead)39 public async Task<IActionResult> ClaimPharmacy(RequestPharmacyHead pharmacy) 39 40 { 40 _pharmacyHeadRepository.Remove(pharmacyHead); 41 await _PHService.ClaimPharmacy(pharmacy); 42 return Ok(); 41 43 } 44 42 45 } 43 46 } -
Farmatiko/appsettings.json
r5d02859 r1454207 10 10 } 11 11 }, 12 "EPPlus": { 13 "ExcelPackage": { 14 "LicenseContext": "NonCommercial" 15 } 16 }, 12 17 "AllowedHosts": "*" 13 18 } -
FarmatikoData/FarmatikoDataContext.cs
r5d02859 r1454207 9 9 10 10 11 public virtual DbSet<HealthFacilit ies> HealthFacilities { get; set; }12 public virtual DbSet<HealthcareWorker s> HealthcareWorkers { get; set; }11 public virtual DbSet<HealthFacility> HealthFacilities { get; set; } 12 public virtual DbSet<HealthcareWorker> HealthcareWorkers { get; set; } 13 13 public virtual DbSet<Pharmacy> Pharmacies { get; set; } 14 14 public virtual DbSet<PharmacyHead> PharmacyHeads { get; set; } … … 16 16 public virtual DbSet<Medicine> Medicines { get; set; } 17 17 public virtual DbSet<MedicineList> MedicineLists { get; set; } 18 18 public virtual DbSet<RequestPharmacyHead> PHRequests { get; set; } 19 19 } 20 20 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r5d02859 r1454207 14 14 } 15 15 //GET 16 public async Task<IQueryable<HealthcareWorker s>> GetAllWorkers()16 public async Task<IQueryable<HealthcareWorker>> GetAllWorkers() 17 17 { 18 18 var Workers = await Task.Run(() => _context.HealthcareWorkers.Take(10)); … … 20 20 } 21 21 22 public async Task<IQueryable<HealthFacilit ies>> GetFacilities()22 public async Task<IQueryable<HealthFacility>> GetFacilities() 23 23 { 24 24 var Facilities = await Task.Run(() => _context.HealthFacilities.Take(10)); … … 26 26 } 27 27 28 public async Task<HealthFacilit ies> GetFacility(int Id)28 public async Task<HealthFacility> GetFacility(int Id) 29 29 { 30 30 var Facility = await _context.HealthFacilities.FindAsync(Id); … … 62 62 } 63 63 64 public async Task<HealthcareWorker s> GetWorker(int id)64 public async Task<HealthcareWorker> GetWorker(int id) 65 65 { 66 66 var Worker = await _context.HealthcareWorkers.FindAsync(id); … … 68 68 } 69 69 70 public async Task<IQueryable<HealthFacilit ies>> SearchFacilities(string query)70 public async Task<IQueryable<HealthFacility>> SearchFacilities(string query) 71 71 { 72 72 var SearchQuery = await Task.Run(() => _context.HealthFacilities … … 95 95 } 96 96 97 public async Task<IQueryable<HealthcareWorker s>> SearchWorkers(string query)97 public async Task<IQueryable<HealthcareWorker>> SearchWorkers(string query) 98 98 { 99 99 var SearchQuery = await Task.Run(() => _context.HealthcareWorkers … … 103 103 return SearchQuery; 104 104 } 105 public async Task<HealthFacility> GetFacilityJSON(string healthFacility) 106 { 107 var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility)).FirstOrDefault()); 108 return Facility; 109 } 105 110 106 111 //POST 107 112 108 public async Task AddWorker(HealthcareWorker sWorker)113 public async Task AddWorker(HealthcareWorker Worker) 109 114 { 110 115 await Task.Run(() => _context.HealthcareWorkers.Add(Worker)); … … 112 117 } 113 118 114 public async Task AddFacility(HealthFacilit ieshealthFacility)119 public async Task AddFacility(HealthFacility healthFacility) 115 120 { 116 121 await Task.Run(() => _context.HealthFacilities.Add(healthFacility)); … … 141 146 await _context.SaveChangesAsync(); 142 147 } 148 149 public async Task UpdateFacility(HealthFacility healthFacility) 150 { 151 var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Id == healthFacility.Id).FirstOrDefault()); 152 Facility.Address = healthFacility.Address; 153 Facility.Email = healthFacility.Email; 154 Facility.Municipality = healthFacility.Municipality; 155 Facility.Name = healthFacility.Name; 156 Facility.Phone = healthFacility.Phone; 157 Facility.Type = healthFacility.Type; 158 await _context.SaveChangesAsync(); 159 } 160 161 public async Task RemoveMedicine(Medicine medicine) 162 { 163 await Task.Run(() => _context.Medicines.Remove(medicine)); 164 await _context.SaveChangesAsync(); 165 } 166 167 public async Task UpdatePandemic(Pandemic pandemic) 168 { 169 var Pandemic = await Task.Run(() => _context.Pandemics.Where(x => x.Id == pandemic.Id).FirstOrDefault()); 170 Pandemic.ActiveGlobal = pandemic.ActiveGlobal; 171 Pandemic.ActiveMK = pandemic.ActiveMK; 172 Pandemic.DeathsGlobal = pandemic.DeathsGlobal; 173 Pandemic.DeathsMK = pandemic.DeathsMK; 174 Pandemic.Name = pandemic.Name; 175 Pandemic.NewMK = pandemic.NewMK; 176 Pandemic.TotalGlobal = pandemic.TotalGlobal; 177 Pandemic.TotalMK = pandemic.TotalMK; 178 await _context.SaveChangesAsync(); 179 } 180 181 public async Task RemovePharmacy(Pharmacy pharmacy) 182 { 183 await Task.Run(() => _context.Pharmacies.Remove(pharmacy)); 184 await _context.SaveChangesAsync(); 185 } 186 //ke vidime 187 public Task UpdateWorker(HealthcareWorker worker) 188 { 189 throw new System.NotImplementedException(); 190 } 191 192 public async Task UpadatePharmacy(Pharmacy pharmacy) 193 { 194 var Pharmacy = await Task.Run(() => _context.Pharmacies.Where(x => x.Id == pharmacy.Id).FirstOrDefault()); 195 Pharmacy.Name = pharmacy.Name; 196 Pharmacy.Location = pharmacy.Location; 197 Pharmacy.WorkAllTime = pharmacy.WorkAllTime; 198 Pharmacy.Address = pharmacy.Address; 199 await _context.SaveChangesAsync(); 200 } 201 //ke vidime 202 public Task UpdateMedicine(Medicine medicine) 203 { 204 throw new System.NotImplementedException(); 205 } 206 207 public async Task RemovePharmacyHead(PharmacyHead pharmacyHead) 208 { 209 var PHead = await Task.Run(() => _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefault()); 210 PHead.DeletedOn = pharmacyHead.DeletedOn; 211 await _context.SaveChangesAsync(); 212 } 213 143 214 } 144 215 } -
FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs
r5d02859 r1454207 1 1 using FarmatikoData.Models; 2 using System; 3 using System.Collections.Generic; 2 4 using System.Linq; 5 using System.Text; 3 6 using System.Threading.Tasks; 4 7 … … 8 11 { 9 12 //GET 10 Task<IQueryable<HealthcareWorker s>> GetAllWorkers();11 Task<IQueryable<HealthFacilit ies>> GetFacilities();12 Task<HealthFacilit ies> GetFacility(int Id);13 Task<IQueryable<HealthcareWorker>> GetAllWorkers(); 14 Task<IQueryable<HealthFacility>> GetFacilities(); 15 Task<HealthFacility> GetFacility(int Id); 13 16 Task<Medicine> GetMedicine(int Id); 14 17 Task<IQueryable<Medicine>> GetMedicines(); … … 16 19 Task<IQueryable<Pharmacy>> GetPharmacies(); 17 20 Task<Pharmacy> GetPharmacy(int id); 18 Task<HealthcareWorker s> GetWorker(int id);19 Task<IQueryable<HealthFacilit ies>> SearchFacilities(string query);21 Task<HealthcareWorker> GetWorker(int id); 22 Task<IQueryable<HealthFacility>> SearchFacilities(string query); 20 23 Task<IQueryable<Medicine>> SearchMedicines(string query); 21 24 Task<IQueryable<Pharmacy>> SearchPharmacies(string query); 22 Task<IQueryable<HealthcareWorkers>> SearchWorkers(string query); 25 Task<IQueryable<HealthcareWorker>> SearchWorkers(string query); 26 Task<HealthFacility> GetFacilityJSON(string healthFacility); 27 23 28 //POST 24 Task AddWorker(HealthcareWorker s worker);25 Task AddFacility(HealthFacilit ies healthFacilities);29 Task AddWorker(HealthcareWorker Worker); 30 Task AddFacility(HealthFacility healthFacility); 26 31 Task AddPharmacy(Pharmacy pharmacy); 27 32 Task AddPharmacyHead(PharmacyHead pharmacyHead); 28 33 Task AddMedicines(Medicine medicine); 29 34 Task AddPandemic(Pandemic pandemic); 35 Task UpdateFacility(HealthFacility healthFacility); 36 Task RemoveMedicine(Medicine medicine); 37 Task UpdatePandemic(Pandemic pandemic); 38 Task RemovePharmacy(Pharmacy pharmacy); 39 Task UpdateWorker(HealthcareWorker worker); 40 Task UpadatePharmacy(Pharmacy pharmacy); 41 Task UpdateMedicine(Medicine medicine); 42 Task RemovePharmacyHead(PharmacyHead pharmacyHead); 30 43 } 31 44 } -
FarmatikoData/Models/HealthFacility.cs
r5d02859 r1454207 9 9 namespace FarmatikoData.Models 10 10 { 11 public class HealthFacilit ies: BaseEntity11 public class HealthFacility : BaseEntity 12 12 { 13 public HealthFacilit ies() { }13 public HealthFacility() { } 14 14 [Required] 15 15 public string Name { get; set; } … … 22 22 public string Email { get; set; } 23 23 public string Phone { get; set; } 24 public HealthFacilit ies(string Name, string Municipality, string Address, string Type, string Email, string Phone)24 public HealthFacility(string Name, string Municipality, string Address, string Type, string Email, string Phone) 25 25 { 26 26 this.Name = Name; -
FarmatikoData/Models/HealthcareWorker.cs
r5d02859 r1454207 8 8 namespace FarmatikoData.Models 9 9 { 10 public class HealthcareWorker s: BaseEntity10 public class HealthcareWorker : BaseEntity 11 11 { 12 public HealthcareWorker s() { }12 public HealthcareWorker() { } 13 13 [Required] 14 14 public string Name { get; set; } … … 16 16 public string Branch { get; set; } 17 17 [Required] 18 public HealthFacilit iesFacility { get; set; }18 public HealthFacility Facility { get; set; } 19 19 public string Title { get; set; } 20 public HealthcareWorker s(string Name, string Branch, HealthFacilitiesFacility, string Title)20 public HealthcareWorker(string Name, string Branch, HealthFacility Facility, string Title) 21 21 { 22 22 this.Name = Name; -
FarmatikoData/Models/PharmacyHead.cs
r5d02859 r1454207 1 using System; 2 using System.Collections.Generic; 1 using System.Collections.Generic; 3 2 using System.ComponentModel.DataAnnotations; 4 using System.Text;5 3 using FarmatikoData.Base; 6 using Microsoft.EntityFrameworkCore;7 4 8 5 namespace FarmatikoData.Models -
FarmatikoServices/FarmatikoServiceInterfaces/IProcessJSONService.cs
r5d02859 r1454207 9 9 public interface IProcessJSONService 10 10 { 11 Task<HashSet<HealthFacilities>> GetProcessedHealthFacilitiesFromJSON(); 12 Task<HashSet<Pandemic>> GetProcessedPandemicsFromJSONApi(); 13 Task<HashSet<HealthcareWorkers>> GetProcessedHealthcareWorkersFromJSON(); 14 Task<HashSet<Medicine>> GetProcessedMedicinesFromJSON(); 11 Task<HealthFacility> GetProcessedHealthFacilitiesFromJSON(); 12 Task<Pandemic> GetProcessedPandemicsFromJSONApi(); 13 Task<HealthcareWorker> GetProcessedHealthcareWorkersFromJSON(); 14 Task<Medicine> GetProcessedMedicinesFromJSON(); 15 Task<Medicine> ReadPharmaciesFromExcel(); 15 16 } 16 17 } -
FarmatikoServices/FarmatikoServiceInterfaces/IService.cs
r5d02859 r1454207 8 8 { 9 9 //GET 10 Task<IQueryable<HealthcareWorkers>> GetAllWorkers(); 11 Task<IQueryable<HealthcareWorkers>> SearchWorkers(string query); 12 Task<HealthcareWorkers> GetWorker(int id); 13 Task<IQueryable<HealthFacilities>> GetFacilities(); 14 Task<IQueryable<HealthFacilities>> SearchFacilities(string query); 15 Task<HealthFacilities> GetFacility(int id); 10 Task<IQueryable<HealthcareWorker>> GetAllWorkers(); 11 Task<IQueryable<HealthcareWorker>> SearchWorkers(string query); 12 Task<HealthcareWorker> GetWorker(int id); 13 Task<IQueryable<HealthFacility>> GetFacilities(); 14 Task<IQueryable<HealthFacility>> SearchFacilities(string query); 15 Task<HealthFacility> GetFacility(int id); 16 Task<HealthFacility> GetFacilityJSON(string healthFacility); 16 17 Task<Medicine> GetMedicine(int id); 17 18 Task<IQueryable<Medicine>> SearchMedicines(string query); … … 22 23 Task<Pharmacy> GetPharmacy(int id); 23 24 //POST 24 Task AddWorker(HealthcareWorker sworker);25 Task AddFacility(HealthFacilit ieshealthFacilities);25 Task AddWorker(HealthcareWorker worker); 26 Task AddFacility(HealthFacility healthFacilities); 26 27 Task AddPharmacy(Pharmacy pharmacy); 27 28 Task AddPharmacyHead(PharmacyHead pharmacyHead); 28 29 Task AddMedicines(Medicine medicine); 29 30 Task AddPandemic(Pandemic pandemic); 31 Task UpdateFacility(HealthFacility healthFacilities); 32 Task RemoveMedicine(Medicine medicine); 33 Task RemovePharmacyHead(PharmacyHead pharmacyHead); 34 Task UpdatePandemic(Pandemic pandemic); 35 Task RemovePharmacy(Pharmacy pharmacy); 36 Task UpdateWorker(HealthcareWorker worker); 37 Task UpdatePharmacy(Pharmacy pharmacy); 30 38 } 31 39 } -
FarmatikoServices/Services/ProcessJSONService.cs
r5d02859 r1454207 11 11 using RestSharp; 12 12 using System.Threading.Tasks; 13 using OfficeOpenXml; 14 using System.IO; 13 15 14 16 namespace FarmatikoServices.Services … … 16 18 public class ProcessJSONService : IProcessJSONService 17 19 { 18 private IHealthFacilityRepository _healthFacilityRepository; 19 private IPandemicRepository _pandemicRepository; 20 private IHealthcareWorkerRepository _healthcareWorkerRepository; 21 private IMedicineRepository _medicineRepository; 20 22 21 private readonly ILogger _logger; 23 p ublic ProcessJSONService(IHealthFacilityRepository healthFacilityRepository, IPandemicRepository pandemicRepository,24 IHealthcareWorkerRepository healthcareWorkerRepository, IMedicineRepository medicineRepository, ILogger logger)22 private readonly IService _service; 23 public ProcessJSONService(ILogger logger, IService service) 25 24 { 26 25 _logger = logger; 27 _healthFacilityRepository = healthFacilityRepository; 28 _pandemicRepository = pandemicRepository; 29 _healthcareWorkerRepository = healthcareWorkerRepository; 30 _medicineRepository = medicineRepository; 26 _service = service; 31 27 } 32 28 33 public async Task<HashSet<HealthFacilities>> GetProcessedHealthFacilitiesFromJSON() 29 public async Task<Medicine> ReadPharmaciesFromExcel() 30 { 31 var client = new WebClient(); 32 string Path = client.DownloadString(@"C:\Users\dslez\Desktop\apteki-fzo.xlsx"); 33 using (var package = new ExcelPackage(new FileInfo(Path))) 34 { 35 var Sheet = package.Workbook.Worksheets[1]; 36 for (int i = 2; i < Sheet.Dimension.End.Row; ++i) 37 { 38 Pharmacy pharmacy = new Pharmacy() 39 { 40 Name = Sheet.Cells[i, 2].Value.ToString(), 41 Address = Sheet.Cells[i, 3].Value.ToString(), 42 Location = Sheet.Cells[i, 4].Value.ToString(), 43 WorkAllTime = false 44 }; 45 await _service.AddPharmacy(pharmacy); 46 } 47 } 48 return null; 49 } 50 51 52 public async Task<HealthFacility> GetProcessedHealthFacilitiesFromJSON() 34 53 { 35 54 try 36 55 { 37 HashSet<HealthFacilities> hashSet = new HashSet<HealthFacilities>();38 56 var client = new WebClient(); 39 57 var json = client.DownloadString(@"C:\Users\dslez\Desktop\ustanovi.json"); … … 51 69 var Phone = obj[11]; 52 70 var Type = obj[5]; 53 HealthFacilities healthFacility = new HealthFacilities(Name, Municipality, Address, Type, Email, Phone); 54 /*healthFacility.Name = Name; 55 healthFacility.Municipality = Municipality; 56 healthFacility.Address = Address; 57 healthFacility.Email = Email; 58 healthFacility.Phone = Phone; 59 healthFacility.Type = Type;*/ 60 //hashSet.Add(healthFacility); 61 await Task.Run(() => _healthFacilityRepository.Add(healthFacility)); 71 HealthFacility healthFacility = new HealthFacility(Name, Municipality, Address, Type, Email, Phone); 72 await Task.Run(() => _service.AddFacility(healthFacility)); 62 73 63 74 } … … 72 83 } 73 84 74 public async Task< HashSet<Pandemic>> GetProcessedPandemicsFromJSONApi()85 public async Task<Pandemic> GetProcessedPandemicsFromJSONApi() 75 86 { 76 87 try … … 97 108 98 109 Pandemic pandemic = new Pandemic(Name, TotalMk, ActiveMk, TotalDeathsMK, NewMK, TotalConfirmed, TotalDeaths, ActiveGlobal); 99 /*pandemic.TotalGlobal = TotalConfirmed; 100 pandemic.ActiveGlobal = TotalConfirmed - (TotalRecovered + TotalDeaths); 101 pandemic.DeathsGlobal = TotalDeaths; 102 pandemic.TotalMK = TotalMk; 103 pandemic.ActiveMK = TotalMk - (TotalRecoveredMK + TotalDeathsMK); 104 pandemic.DeathsMK = TotalDeathsMK; 105 pandemic.NewMK = NewMK; 106 pandemic.Name = "Coronavirus";*/ 107 await Task.Run(() => _pandemicRepository.Add(pandemic)); 110 await Task.Run(() => _service.AddPandemic(pandemic)); 108 111 } 109 112 catch (Exception e) … … 114 117 } 115 118 116 public async Task<H ashSet<HealthcareWorkers>> GetProcessedHealthcareWorkersFromJSON()119 public async Task<HealthcareWorker> GetProcessedHealthcareWorkersFromJSON() 117 120 { 118 121 try … … 131 134 var FacilityName = obj[1]; 132 135 var Title = obj[3]; 133 HealthFacilit ies facility = _healthFacilityRepository.GetByName(FacilityName);134 HealthFacilit ies Facility = new HealthFacilities(facility.Name, facility.Municipality, facility.Address,136 HealthFacility facility = await _service.GetFacilityJSON(FacilityName); 137 HealthFacility Facility = new HealthFacility(facility.Name, facility.Municipality, facility.Address, 135 138 facility.Type, facility.Email, facility.Phone); 136 HealthcareWorker s healthcareWorker = new HealthcareWorkers(Name, Branch, Facility, Title);139 HealthcareWorker healthcareWorker = new HealthcareWorker(Name, Branch, Facility, Title); 137 140 /*Facility.Name = obj[1]; 138 141 Facility.Municipality = "WorkerFacilityMunicipality"; … … 142 145 healthcareWorker.Facility = Facility; 143 146 healthcareWorker.Title = Title;*/ 144 await Task.Run(() => _ healthcareWorkerRepository.Add(healthcareWorker));147 await Task.Run(() => _service.AddWorker(healthcareWorker)); 145 148 } 146 149 } … … 152 155 } 153 156 154 public async Task< HashSet<Medicine>> GetProcessedMedicinesFromJSON()157 public async Task<Medicine> GetProcessedMedicinesFromJSON() 155 158 { 156 159 try … … 180 183 medicine.Price = Price; 181 184 medicine.Packaging = Packaging;*/ 182 await Task.Run(() => _ medicineRepository.Add(medicine));185 await Task.Run(() => _service.AddMedicines(medicine)); 183 186 } 184 187 } -
FarmatikoServices/Services/Service.cs
r5d02859 r1454207 17 17 18 18 //GET 19 public async Task<IQueryable<HealthcareWorker s>> GetAllWorkers()19 public async Task<IQueryable<HealthcareWorker>> GetAllWorkers() 20 20 { 21 21 var Workers = await _repository.GetAllWorkers(); … … 23 23 } 24 24 25 public async Task<IQueryable<HealthFacilit ies>> GetFacilities()25 public async Task<IQueryable<HealthFacility>> GetFacilities() 26 26 { 27 27 var Facilities = await _repository.GetFacilities(); … … 29 29 } 30 30 31 public async Task<HealthFacilit ies> GetFacility(int id)31 public async Task<HealthFacility> GetFacility(int id) 32 32 { 33 33 var Facility = await _repository.GetFacility(id); … … 65 65 } 66 66 67 public async Task<HealthcareWorker s> GetWorker(int id)67 public async Task<HealthcareWorker> GetWorker(int id) 68 68 { 69 69 var Worker = await _repository.GetWorker(id); … … 71 71 } 72 72 73 public async Task<IQueryable<HealthFacilit ies>> SearchFacilities(string query)73 public async Task<IQueryable<HealthFacility>> SearchFacilities(string query) 74 74 { 75 75 var SearchQuery = await _repository.SearchFacilities(query); … … 89 89 } 90 90 91 public async Task<IQueryable<HealthcareWorker s>> SearchWorkers(string query)91 public async Task<IQueryable<HealthcareWorker>> SearchWorkers(string query) 92 92 { 93 93 var SearchQuery = await _repository.SearchWorkers(query); … … 97 97 98 98 //POST (ADD NEW OBJECTS) 99 public Task AddFacility(HealthFacilities healthFacilities) 99 //za json(Sys updateer) 100 public async Task AddFacility(HealthFacility healthFacilities) 100 101 { 101 102 if (healthFacilities != null) 102 _repository.AddFacility(healthFacilities);103 await _repository.AddFacility(healthFacilities); 103 104 throw new Exception("Facility is null"); 104 105 } 105 106 public Task AddMedicines(Medicine medicine)106 //za json(Sys updateer) 107 public async Task AddMedicines(Medicine medicine) 107 108 { 108 109 if (medicine != null) 109 _repository.AddMedicines(medicine);110 await _repository.AddMedicines(medicine); 110 111 throw new Exception("Medicine is null"); 111 112 } 112 113 public Task AddPandemic(Pandemic pandemic)113 //za json(Sys updateer) 114 public async Task AddPandemic(Pandemic pandemic) 114 115 { 115 116 if (pandemic != null) 116 _repository.AddPandemic(pandemic);117 await _repository.AddPandemic(pandemic); 117 118 throw new Exception("Pandemic is null"); 118 119 } 119 120 public Task AddPharmacy(Pharmacy pharmacy)120 // Samo PharmacyHead i Admin imaat pristap 121 public async Task AddPharmacy(Pharmacy pharmacy) 121 122 { 122 123 if (pharmacy != null) 123 _repository.AddPharmacy(pharmacy);124 await _repository.AddPharmacy(pharmacy); 124 125 throw new Exception("Pharmacy is null"); 125 126 } 126 127 public Task AddPharmacyHead(PharmacyHead pharmacyHead)127 // Ovaa kontrola ja ima samo admin 128 public async Task AddPharmacyHead(PharmacyHead pharmacyHead) 128 129 { 129 130 if (pharmacyHead != null) 130 _repository.AddPharmacyHead(pharmacyHead); 131 { 132 var Medicines = await _repository.GetMedicines(); 133 foreach (var med in Medicines) 134 { 135 MedicineList medicine = new MedicineList() 136 { 137 Medicine = med, 138 HasMedicine = false 139 }; 140 pharmacyHead.MedicineLists.Add(medicine); 141 } 142 await _repository.AddPharmacyHead(pharmacyHead); 143 } 131 144 throw new Exception("PharmacyHead is null"); 132 145 } 133 134 public Task AddWorker(HealthcareWorkersworker)146 //za json(Sys updateer) 147 public async Task AddWorker(HealthcareWorker worker) 135 148 { 136 149 if (worker != null) 137 _repository.AddWorker(worker);150 await _repository.AddWorker(worker); 138 151 throw new Exception("Worker is null"); 152 } 153 154 //za json(Sys updateer) 155 public async Task UpdateFacility(HealthFacility healthFacilities) 156 { 157 if (healthFacilities != null) 158 await _repository.UpdateFacility(healthFacilities); 159 throw new Exception("Facility is null"); 160 } 161 //PharmacyHead 162 public async Task RemoveMedicine(Medicine medicine) 163 { 164 if (medicine != null) 165 await _repository.RemoveMedicine(medicine); 166 throw new Exception("Medicine is null"); 167 } 168 //PharmacyHead 169 public async Task UpdateMedicine(Medicine medicine) 170 { 171 if (medicine != null) 172 await _repository.UpdateMedicine(medicine); 173 throw new Exception("Medicine is null"); 174 } 175 //za json(Sys updateer) 176 public async Task UpdatePandemic(Pandemic pandemic) 177 { 178 if (pandemic != null) 179 await _repository.UpdatePandemic(pandemic); 180 throw new Exception("Pandemic is null"); 181 } 182 //PharmacyHead 183 public async Task RemovePharmacy(Pharmacy pharmacy) 184 { 185 if (pharmacy != null) 186 await _repository.RemovePharmacy(pharmacy); 187 throw new Exception("Pharmacy is null"); 188 } 189 //PharamcyHead 190 public async Task UpdatePharmacy(Pharmacy pharmacy) 191 { 192 if (pharmacy != null) 193 await _repository.UpadatePharmacy(pharmacy); 194 throw new Exception("Pharmacy is null"); 195 } 196 //za json(Sys updateer) 197 public async Task UpdateWorker(HealthcareWorker worker) 198 { 199 if (worker != null) 200 await _repository.UpdateWorker(worker); 201 throw new Exception("Worker is null"); 202 } 203 204 public async Task RemovePharmacyHead(PharmacyHead pharmacyHead) 205 { 206 if (pharmacyHead != null) 207 { 208 pharmacyHead.DeletedOn = DateTime.UtcNow; 209 await _repository.RemovePharmacyHead(pharmacyHead); 210 } 211 else throw new Exception("PharmacyHead is null."); 212 } 213 214 public async Task<HealthFacility> GetFacilityJSON(string healthFacility) 215 { 216 if (healthFacility != null) 217 return await _repository.GetFacilityJSON(healthFacility); 218 return null; 139 219 } 140 220
Note:
See TracChangeset
for help on using the changeset viewer.