Changeset 6f203af for FarmatikoServices
- Timestamp:
- 10/28/20 22:06:48 (4 years ago)
- Branches:
- master
- Children:
- 993189e
- Parents:
- 1454207
- Location:
- FarmatikoServices
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoServices/FarmatikoServiceInterfaces/IAdminService.cs
r1454207 r6f203af 10 10 public interface IAdminService 11 11 { 12 Task<I Queryable<PharmacyHead>> GetPharmacyHeads();13 Task<I Queryable<RequestPharmacyHead>> GetCalimingRequests();14 TaskRejectRequest(RequestPharmacyHead req);12 Task<IEnumerable<PharmacyHead>> GetPharmacyHeads(); 13 Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests(); 14 bool RejectRequest(RequestPharmacyHead req); 15 15 } 16 16 } -
FarmatikoServices/FarmatikoServiceInterfaces/IPHService.cs
r1454207 r6f203af 10 10 public interface IPHService 11 11 { 12 Task<I Queryable<PharmacyHead>> GetPharmacyHeadInfo(string Token);12 Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo(string Token); 13 13 Task UpdatePharmacyHead(PharmacyHead pharmacyHead); 14 14 Task<int> Login(PharmacyHead pharmacyHead); 15 Task ClaimPharmacy(RequestPharmacyHead pharmacy); 15 Task<bool> ClaimPharmacy(RequestPharmacyHead pharmacy); 16 Task<PharmacyHead> GetPharmacyHeadByIdAsync(int id); 17 Task<bool> Add(PharmacyHead pharmacyHead); 18 Task<bool> Remove(int id); 19 Task<bool> RemoveClaimingRequest(int id); 16 20 } 17 21 } -
FarmatikoServices/FarmatikoServiceInterfaces/IService.cs
r1454207 r6f203af 1 1 using FarmatikoData.Models; 2 using System.Collections.Generic; 2 3 using System.Linq; 3 4 using System.Threading.Tasks; … … 8 9 { 9 10 //GET 10 Task<I Queryable<HealthcareWorker>> GetAllWorkers();11 Task<I Queryable<HealthcareWorker>> SearchWorkers(string query);11 Task<IEnumerable<HealthcareWorker>> GetAllWorkers(); 12 Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query); 12 13 Task<HealthcareWorker> GetWorker(int id); 13 Task<I Queryable<HealthFacility>> GetFacilities();14 Task<I Queryable<HealthFacility>> SearchFacilities(string query);14 Task<IEnumerable<HealthFacility>> GetFacilities(); 15 Task<IEnumerable<HealthFacility>> SearchFacilities(string query); 15 16 Task<HealthFacility> GetFacility(int id); 16 17 Task<HealthFacility> GetFacilityJSON(string healthFacility); 17 18 Task<Medicine> GetMedicine(int id); 18 Task<I Queryable<Medicine>> SearchMedicines(string query);19 Task<I Queryable<Medicine>> GetMedicines();19 Task<IEnumerable<Medicine>> SearchMedicines(string query); 20 Task<IEnumerable<Medicine>> GetMedicines(); 20 21 Task<Pandemic> GetPandemic(); 21 Task<I Queryable<Pharmacy>> GetPharmacies();22 Task<I Queryable<Pharmacy>> SearchPharmacies(string query);22 Task<IEnumerable<Pharmacy>> GetPharmacies(); 23 Task<IEnumerable<Pharmacy>> SearchPharmacies(string query); 23 24 Task<Pharmacy> GetPharmacy(int id); 24 25 //POST … … 31 32 Task UpdateFacility(HealthFacility healthFacilities); 32 33 Task RemoveMedicine(Medicine medicine); 33 Task RemovePharmacyHead( PharmacyHead pharmacyHead);34 Task RemovePharmacyHead(int Id); 34 35 Task UpdatePandemic(Pandemic pandemic); 35 36 Task RemovePharmacy(Pharmacy pharmacy); -
FarmatikoServices/FarmatikoServices.csproj
r1454207 r6f203af 6 6 7 7 <ItemGroup> 8 <PackageReference Include="EPPlus" Version="5.4.0" /> 8 9 <PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> 9 10 <PackageReference Include="RestSharp" Version="106.11.4" /> -
FarmatikoServices/Services/AdminService.cs
r1454207 r6f203af 5 5 using System.Collections.Generic; 6 6 using System.Linq; 7 using System.Text;8 7 using System.Threading.Tasks; 9 8 … … 18 17 } 19 18 20 public async Task<I Queryable<RequestPharmacyHead>> GetCalimingRequests()19 public async Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests() 21 20 { 22 var req = await Task.Run(() => _adminRepo.GetClaimingRequests()); 23 return req; 21 var req = await _adminRepo.GetClaimingRequests(); 22 if (req != null) 23 return req; 24 throw new Exception("No data is found."); 24 25 } 25 26 26 public async Task<I Queryable<PharmacyHead>> GetPharmacyHeads()27 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads() 27 28 { 28 var PHeads = await Task.Run(() => _adminRepo.GetPharmacyHeads()); 29 return PHeads; 29 var PHeads = await _adminRepo.GetPharmacyHeads(); 30 var list = PHeads.Select(x => x.DeletedOn == null); 31 if (list != null) 32 { 33 return PHeads; 34 } 35 throw new Exception("No data is found."); 30 36 } 31 37 32 public async TaskRejectRequest(RequestPharmacyHead req)38 public bool RejectRequest(RequestPharmacyHead req) 33 39 { 34 await _adminRepo.RemoveClaimRequest(req); 40 if (req != null) 41 { 42 _adminRepo.RemoveClaimRequest(req); 43 return true; 44 } 45 return false; 35 46 } 36 47 } -
FarmatikoServices/Services/PHService.cs
r1454207 r6f203af 18 18 } 19 19 20 public async Task ClaimPharmacy(RequestPharmacyHead pharmacy)20 public async Task<bool> ClaimPharmacy(RequestPharmacyHead pharmacy) 21 21 { 22 await _iPHRepo.ClaimPharmacy(pharmacy); 22 if (pharmacy != null) 23 { 24 await _iPHRepo.ClaimPharmacy(pharmacy); 25 return true; 26 } 27 return false; 23 28 } 24 29 25 public Task<IQueryable<PharmacyHead>> GetPharmacyHeadInfo(string Token)30 public async Task<PharmacyHead> GetPharmacyHeadByIdAsync(int id) 26 31 { 27 throw new NotImplementedException(); 32 PharmacyHead Phead = null; 33 if (id >= 0) 34 Phead = await _iPHRepo.GetPharmacyHeadByIdAsync(id); 35 if (Phead != null) 36 return Phead; 37 throw new Exception("No data found."); 38 } 39 40 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo(string Token) 41 { 42 var PHeads = await _iPHRepo.GetPharmacyHeadInfo(); 43 if (PHeads != null) 44 return PHeads; 45 throw new Exception("No Pharmacy heads found."); 28 46 } 29 47 30 48 public async Task<int> Login(PharmacyHead pharmacyHead) 31 49 { 32 var PHead = await Task.Run(() => _iPHRepo.GetPharmacyHead(pharmacyHead));50 var PHead = await _iPHRepo.GetPharmacyHeadByIdAsync(pharmacyHead.Id); 33 51 if (PHead.Password.Equals(pharmacyHead.Password)) 34 52 return PHead.Id; … … 43 61 else throw new Exception("PharmacyHead has a null value."); 44 62 } 63 public async Task<bool> Add(PharmacyHead pharmacyHead) 64 { 65 if (pharmacyHead != null) 66 { 67 await _iPHRepo.Add(pharmacyHead); 68 return true; 69 } 70 return false; 71 } 72 73 public async Task<bool> Remove(int id) 74 { 75 PharmacyHead Phead = await _iPHRepo.GetPharmacyHeadByIdAsync(id); 76 if (Phead != null && id >= 0) 77 { 78 Phead.DeletedOn = DateTime.UtcNow; 79 await _iPHRepo.Remove(Phead); 80 return true; 81 } 82 return false; 83 } 84 85 public async Task<bool> RemoveClaimingRequest(int id) 86 { 87 if (id >= 0) 88 { 89 await _iPHRepo.RemoveClaimingRequest(id); 90 return true; 91 } 92 return false; 93 } 45 94 } 46 95 } -
FarmatikoServices/Services/ProcessJSONService.cs
r1454207 r6f203af 29 29 public async Task<Medicine> ReadPharmaciesFromExcel() 30 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()31 try 32 { 33 var client = new WebClient(); 34 string Path = client.DownloadString(@"C:\Users\dslez\Desktop\apteki-fzo.xlsx"); 35 using (var package = new ExcelPackage(new FileInfo(Path))) 36 { 37 var Sheet = package.Workbook.Worksheets[1]; 38 for (int i = 2; i < Sheet.Dimension.End.Row; ++i) 39 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 } 40 Pharmacy pharmacy = new Pharmacy() 41 { 42 Name = Sheet.Cells[i, 2].Value.ToString(), 43 Address = Sheet.Cells[i, 3].Value.ToString(), 44 Location = Sheet.Cells[i, 4].Value.ToString(), 45 WorkAllTime = false 46 }; 47 await _service.AddPharmacy(pharmacy); 48 } 49 } 50 51 } 52 catch(Exception e) 53 { 54 _logger.LogInformation(e.Message); 55 throw new Exception("Cannot process Medicines from Excel."); 47 56 } 48 57 return null; -
FarmatikoServices/Services/Service.cs
r1454207 r6f203af 3 3 using FarmatikoServices.FarmatikoServiceInterfaces; 4 4 using System; 5 using System.Collections.Generic; 5 6 using System.Linq; 6 7 using System.Threading.Tasks; … … 17 18 18 19 //GET 19 public async Task<I Queryable<HealthcareWorker>> GetAllWorkers()20 public async Task<IEnumerable<HealthcareWorker>> GetAllWorkers() 20 21 { 21 22 var Workers = await _repository.GetAllWorkers(); … … 23 24 } 24 25 25 public async Task<I Queryable<HealthFacility>> GetFacilities()26 public async Task<IEnumerable<HealthFacility>> GetFacilities() 26 27 { 27 28 var Facilities = await _repository.GetFacilities(); … … 41 42 } 42 43 43 public async Task<I Queryable<Medicine>> GetMedicines()44 public async Task<IEnumerable<Medicine>> GetMedicines() 44 45 { 45 46 var Medicines = await _repository.GetMedicines(); … … 53 54 } 54 55 55 public async Task<I Queryable<Pharmacy>> GetPharmacies()56 public async Task<IEnumerable<Pharmacy>> GetPharmacies() 56 57 { 57 58 var Pharmacies = await _repository.GetPharmacies(); … … 71 72 } 72 73 73 public async Task<I Queryable<HealthFacility>> SearchFacilities(string query)74 public async Task<IEnumerable<HealthFacility>> SearchFacilities(string query) 74 75 { 75 76 var SearchQuery = await _repository.SearchFacilities(query); … … 77 78 } 78 79 79 public async Task<I Queryable<Medicine>> SearchMedicines(string query)80 public async Task<IEnumerable<Medicine>> SearchMedicines(string query) 80 81 { 81 82 var SearchQuery = await _repository.SearchMedicines(query); … … 83 84 } 84 85 85 public async Task<I Queryable<Pharmacy>> SearchPharmacies(string query)86 public async Task<IEnumerable<Pharmacy>> SearchPharmacies(string query) 86 87 { 87 88 var SearchQuery = await _repository.SearchPharmacies(query); … … 89 90 } 90 91 91 public async Task<I Queryable<HealthcareWorker>> SearchWorkers(string query)92 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query) 92 93 { 93 94 var SearchQuery = await _repository.SearchWorkers(query); … … 202 203 } 203 204 204 public async Task RemovePharmacyHead( PharmacyHead pharmacyHead)205 { 206 if ( pharmacyHead != null)205 public async Task RemovePharmacyHead(int Id) 206 { 207 if (Id > 0) 207 208 { 208 pharmacyHead.DeletedOn = DateTime.UtcNow; 209 await _repository.RemovePharmacyHead(pharmacyHead); 209 await _repository.RemovePharmacyHead(Id); 210 210 } 211 else throw new Exception("PharmacyHead is null.");211 throw new Exception("Index out of bounds."); 212 212 } 213 213
Note:
See TracChangeset
for help on using the changeset viewer.