Changeset 6f203af
- Timestamp:
- 10/28/20 22:06:48 (4 years ago)
- Branches:
- master
- Children:
- 993189e
- Parents:
- 1454207
- Files:
-
- 1 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/shared/data.service.ts
r1454207 r6f203af 160 160 //PharmacyHead POST 161 161 insertPharmacyHead(head: IPharmacyHead) : Observable<IPharmacyHead> { 162 return this.http.post<IPharmacyHead>(this.basePharmacyHead , head)162 return this.http.post<IPharmacyHead>(this.basePharmacyHead + '/add', head) 163 163 .pipe( 164 164 map((data) => { … … 189 189 //PharmacyHead DELETE 190 190 deletePharmacyHead(id: string) : Observable<boolean> { 191 return this.http.delete<boolean>(this.basePharmacyHead + '/ ' + id)191 return this.http.delete<boolean>(this.basePharmacyHead + '/delete/' + id) 192 192 .pipe(catchError(this.handleError)); 193 193 } -
Farmatiko/Controllers/AdminController.cs
r1454207 r6f203af 23 23 //GET 24 24 [HttpGet] 25 public async Task<IQueryable<PharmacyHead>> GetPharmacyHeads() 25 [Route("api/pharmacyhead")] 26 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads() 26 27 { 27 28 return await _adminService.GetPharmacyHeads(); … … 29 30 30 31 [HttpGet] 31 public async Task<IQueryable<RequestPharmacyHead>> GetClaimingRequests() 32 [Route("api/pharmacyhead/requests")] 33 public async Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests() 32 34 { 33 return await _adminService.GetC alimingRequests();35 return await _adminService.GetClaimingRequests(); 34 36 } 35 37 … … 37 39 //POST 38 40 [HttpPost] 41 [Route("api/pharmacyhead/add")] 39 42 public async Task<IActionResult> AddPharmacyHead(PharmacyHead pharmacyHead) 40 43 { … … 44 47 45 48 [HttpPost] 46 public async Task<IActionResult> RemovePharmacyHead(PharmacyHead pharmacyHead) 49 [Route("api/pharmacyhead/delete/{Id}")] 50 public async Task<IActionResult> RemovePharmacyHead([FromQuery]int Id) 47 51 { 48 await _service.RemovePharmacyHead( pharmacyHead);52 await _service.RemovePharmacyHead(Id); 49 53 return Ok(); 50 54 } 51 55 [HttpPost] 52 public async Task<IActionResult>RejectRequset(RequestPharmacyHead req)56 public IActionResult RejectRequset(RequestPharmacyHead req) 53 57 { 54 await_adminService.RejectRequest(req);55 return Ok( );58 bool Success = _adminService.RejectRequest(req); 59 return Ok(Success); 56 60 } 57 61 [HttpPost] -
Farmatiko/Controllers/FarmatikoController.cs
r1454207 r6f203af 1 using System. Linq;1 using System.Collections.Generic; 2 2 using System.Threading.Tasks; 3 3 using FarmatikoData.Models; … … 8 8 { 9 9 [ApiController] 10 [Route("api/[action]")]11 10 public class FarmatikoController : Controller 12 11 { … … 19 18 //Get 20 19 [HttpGet] 21 [Route(" /api/workers")]22 public async Task<I Queryable<HealthcareWorker>> GetWorkers()20 [Route("api/workers")] 21 public async Task<IEnumerable<HealthcareWorker>> GetWorkers() 23 22 { 24 23 var Workers = await _service.GetAllWorkers(); … … 26 25 } 27 26 [HttpGet] 28 [Route(" /api/workers/search/{Query}")]29 public async Task<I Queryable<HealthcareWorker>> SearchWorkers(string Query)27 [Route("api/workers/search/{Query}")] 28 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers(string Query) 30 29 { 31 30 return await _service.SearchWorkers(Query); 32 31 } 33 32 [HttpGet] 34 [Route(" /api/workers/{id}")]33 [Route("api/workers/{id}")] 35 34 public async Task<HealthcareWorker> GetWorker(int Id) 36 35 { … … 43 42 //Get 44 43 [HttpGet] 45 [Route(" /api/facilities")]46 public async Task<I Queryable<HealthFacility>> GetFacilities()44 [Route("api/facilities")] 45 public async Task<IEnumerable<HealthFacility>> GetFacilities() 47 46 { 48 47 return await _service.GetFacilities(); 49 48 } 50 49 [HttpGet] 51 [Route(" /api/facilities/search/{Query}")]52 public async Task<I Queryable<HealthFacility>> SearchFacilities(string Query)50 [Route("api/facilities/search/{Query}")] 51 public async Task<IEnumerable<HealthFacility>> SearchFacilities(string Query) 53 52 { 54 53 return await _service.SearchFacilities(Query); 55 54 } 56 55 [HttpGet] 57 [Route(" /api/facilities/{Id}")]56 [Route("api/facilities/{Id}")] 58 57 public async Task<HealthFacility> GetFacility(int Id) 59 58 { … … 65 64 //Get 66 65 [HttpGet] 67 [Route(" /api/medicines")]68 public async Task<I Queryable<Medicine>> GetMedicines()66 [Route("api/medicines")] 67 public async Task<IEnumerable<Medicine>> GetMedicines() 69 68 { 70 69 return await _service.GetMedicines(); 71 70 } 72 71 [HttpGet] 73 [Route(" /api/medicines/search/{Query}")]74 public async Task<I Queryable<Medicine>> SearchMedicines(string Query)72 [Route("api/medicines/search/{Query}")] 73 public async Task<IEnumerable<Medicine>> SearchMedicines(string Query) 75 74 { 76 75 return await _service.SearchMedicines(Query); 77 76 } 78 77 [HttpGet] 79 [Route(" /api/medicines/{Id}")]78 [Route("api/medicines/{Id}")] 80 79 public async Task<Medicine> GetMedicine(int Id) 81 80 { 82 81 return await _service.GetMedicine(Id); 83 82 } 84 //POST85 86 83 //Pandemic 87 84 [HttpGet] 88 [Route(" /api/pandemic")]85 [Route("api/pandemic")] 89 86 public async Task<Pandemic> GetPandemic() 90 87 { … … 94 91 //GET 95 92 [HttpGet] 96 [Route(" /api/pharmacy")]97 public async Task<I Queryable<Pharmacy>> GetPharmacies()93 [Route("api/pharmacy")] 94 public async Task<IEnumerable<Pharmacy>> GetPharmacies() 98 95 { 99 96 return await _service.GetPharmacies(); 100 97 } 101 98 [HttpGet] 102 [Route(" /api/pharmacy/search/{Query}")]103 public async Task<I Queryable<Pharmacy>> SearchPharmacies(string Query)99 [Route("api/pharmacy/search/{Query}")] 100 public async Task<IEnumerable<Pharmacy>> SearchPharmacies(string Query) 104 101 { 105 102 return await _service.SearchPharmacies(Query); 106 103 } 107 104 [HttpGet] 108 [Route(" /api/pharmacy/{Id}")]105 [Route("api/pharmacy/{Id}")] 109 106 public async Task<Pharmacy> GetPharmacy(int Id) 110 107 { -
Farmatiko/Controllers/PharmacyHeadController.cs
r1454207 r6f203af 1 using System.Linq; 1 using System.Collections; 2 using System.Collections.Generic; 3 using System.Linq; 2 4 using System.Threading.Tasks; 3 5 using FarmatikoData.FarmatikoRepoInterfaces; … … 9 11 { 10 12 [ApiController] 11 [Route("api/[action]")]12 13 public class PharmacyHeadController : Controller 13 14 { … … 17 18 _PHService = PHService; 18 19 } 19 20 20 21 //GET 21 22 //Mi trebaat rutite 22 23 [HttpGet] 23 public async Task<IQueryable<PharmacyHead>> GetPharmacyHeadInfo(string Token) 24 [Route("api/pharmacyhead")] 25 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo(string Token) 24 26 { 25 return await _PHService.GetPharmacyHeadInfo(Token); 27 var PHeads = await _PHService.GetPharmacyHeadInfo(Token); 28 return PHeads; 29 } 30 [HttpGet] 31 [Route("api/pharmacyhead/{Id}")] 32 public async Task<PharmacyHead> GetPharmacyHeadById(int Id) 33 { 34 var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id); 35 return Phead; 26 36 } 27 37 //POST 28 38 [HttpPost] 29 public async Task<int> Login(PharmacyHead pharmacyHead) 39 [Route("api/pharmacyhead/add")] 40 public async Task<IActionResult> AddPharmacyHead(PharmacyHead pharmacyHead) 41 { 42 bool Success = await _PHService.Add(pharmacyHead); 43 return Ok(Success); 44 } 45 46 [HttpPost] 47 [Route("api/pharmacyhead/login")] 48 public async Task<int> Login([FromBody]PharmacyHead pharmacyHead) 30 49 { 31 50 return await _PHService.Login(pharmacyHead); 32 51 } 33 [HttpPost] 34 public async Task UpdatePharmacyHead(PharmacyHead pharmacyHead) 52 [HttpPut] 53 [Route("api/pharmacyhead/{Id}")] 54 public async Task UpdatePharmacyHead([FromBody]PharmacyHead pharmacyHead) 35 55 { 36 56 await _PHService.UpdatePharmacyHead(pharmacyHead); 37 57 } 38 58 [HttpPost] 59 [Route("api/pharmacyhead/requests")] 39 60 public async Task<IActionResult> ClaimPharmacy(RequestPharmacyHead pharmacy) 40 61 { 41 await _PHService.ClaimPharmacy(pharmacy); 42 return Ok(); 62 bool Success = await _PHService.ClaimPharmacy(pharmacy); 63 return Ok(Success); 64 } 65 [HttpDelete] 66 [Route("api/pharmacyhead/delete/{Id}")] 67 public async Task<IActionResult> Remove([FromQuery] int Id) 68 { 69 bool Success = await _PHService.Remove(Id); 70 return Ok(Success); 71 } 72 [HttpPost] 73 [Route("api/pharmacyhead/requests/{Id}")] 74 public async Task<IActionResult> RemoveClaimingRequest([FromQuery] int Id) 75 { 76 bool Success = await _PHService.RemoveClaimingRequest(Id); 77 return Ok(Success); 43 78 } 44 79 -
Farmatiko/Startup.cs
r1454207 r6f203af 48 48 services.AddEntityFrameworkNpgsql().AddDbContext<FarmatikoDataContext>(opt => opt.UseNpgsql(connectionString)); 49 49 50 services.AddTransient<IHealthFacilityRepository, HealthFacilityRepository>(); 51 services.AddTransient<IHealthFacilityService, HealthFacilityService>(); 50 services.AddTransient<IPHRepo, PHRepo>(); 51 services.AddTransient<IRepository, Repository>(); 52 services.AddTransient<IAdminRepo, AdminRepo>(); 52 53 53 services.AddTransient<IHealthcareWorkerRepository, HealthcareWorkerRepository>(); 54 services.AddTransient<IHealthcareWorkerService, HealthcareWorkerService>(); 55 56 services.AddTransient<IMedicineRepository, MedicineRepository>(); 57 services.AddTransient<IMedicineService, MedicineService>(); 58 59 services.AddTransient<IMedicineListRepository, MedicineListRepository>(); 60 services.AddTransient<IMedicineListService, MedicineListService>(); 61 62 services.AddTransient<IPandemicRepository, PandemicRepository>(); 63 services.AddTransient<IPandemicService, PandemicService>(); 64 65 services.AddTransient<IPharmacyHeadRepository, PharmacyHeadRepository>(); 66 services.AddTransient<IPharmacyHeadService, PharmacyHeadService>(); 67 68 services.AddTransient<IPharmacyRepository, PharmacyRepository>(); 69 services.AddTransient<IPharmacyService, PharmacyService>(); 54 services.AddTransient<IPHService, PHService>(); 55 services.AddTransient<IAdminService, AdminService>(); 56 services.AddTransient<IService, Service>(); 70 57 71 58 services.AddTransient<IProcessJSONService, ProcessJSONService>(); -
FarmatikoData/FarmatikoRepo/AdminRepo.cs
r1454207 r6f203af 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore; 3 4 using System; 4 5 using System.Collections.Generic; … … 17 18 } 18 19 19 public async Task<I Queryable<RequestPharmacyHead>> GetClaimingRequests()20 public async Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests() 20 21 { 21 var reqs = await Task.Run(() => _context.PHRequests.OrderBy(x => x.Head.Name));22 var reqs = await _context.PHRequests.OrderBy(x => x.Head.Name).ToListAsync(); 22 23 return reqs; 23 24 } 24 25 25 26 //GET 26 public async Task<I Queryable<PharmacyHead>> GetPharmacyHeads()27 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeads() 27 28 { 28 var PHeads = await Task.Run(() => _context.PharmacyHeads.OrderBy(x => x.Name));29 var PHeads = await _context.PharmacyHeads.OrderBy(x => x.Name).ToListAsync(); 29 30 return PHeads; 30 31 } 31 32 //POST 32 public async TaskRemoveClaimRequest(RequestPharmacyHead req)33 public void RemoveClaimRequest(RequestPharmacyHead req) 33 34 { 34 await Task.Run(() => _context.PHRequests.Remove(req));35 await _context.SaveChangesAsync();35 _context.PHRequests.Remove(req); 36 _context.SaveChanges(); 36 37 } 37 38 } -
FarmatikoData/FarmatikoRepo/PHRepo.cs
r1454207 r6f203af 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System;3 using Microsoft.EntityFrameworkCore; 4 4 using System.Collections.Generic; 5 5 using System.Linq; 6 using System.Text;7 6 using System.Threading.Tasks; 8 7 … … 16 15 _context = context; 17 16 } 18 19 public async Task ClaimPharmacy(RequestPharmacyHead pharmacy)17 //GET 18 public async Task<PharmacyHead> GetPharmacyHeadByIdAsync(int id) 20 19 { 21 await Task.Run(() => _context.PHRequests.Add(pharmacy)); 22 await _context.SaveChangesAsync(); 23 } 24 25 public async Task<PharmacyHead> GetPharmacyHead(PharmacyHead pharmacyHead) 26 { 27 var Phead = await Task.Run(() => _context.PharmacyHeads.Where(x => x.Email.Equals(pharmacyHead.Email)).FirstOrDefault()); 20 var Phead = await _context.PharmacyHeads.Where(x => x.Id == id).FirstOrDefaultAsync(); 28 21 return Phead; 29 22 } 30 23 31 public async Task<I Queryable<PharmacyHead>> GetPharmacyHeadInfo()24 public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo() 32 25 { 33 var PHeadInfo = await Task.Run(() => _context.PharmacyHeads.Take(10)); 26 var PHeadInfo = await _context.PharmacyHeads.Take(10).Where(x => x.DeletedOn == null) 27 .Select(x => new PharmacyHead 28 { 29 Id = x.Id, 30 Name = x.Name, 31 Email = x.Email, 32 Password = x.Password, 33 MedicineLists = x.MedicineLists, 34 PharmaciesList = x.PharmaciesList 35 }).ToListAsync(); 34 36 return PHeadInfo; 35 37 } 36 38 //POST 37 39 public async Task UpdatePharmacyHead(PharmacyHead pharmacyHead) 38 40 { 39 var EditedPHead = await Task.Run(() => _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefault());41 var EditedPHead = await _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefaultAsync(); 40 42 EditedPHead.Email = pharmacyHead.Email; 41 43 EditedPHead.Name = pharmacyHead.Name; … … 45 47 await _context.SaveChangesAsync(); 46 48 } 49 public async Task ClaimPharmacy(RequestPharmacyHead pharmacy) 50 { 51 await _context.PHRequests.AddAsync(pharmacy); 52 await _context.SaveChangesAsync(); 53 } 54 public async Task Add(PharmacyHead pharmacyHead) 55 { 56 await _context.PharmacyHeads.AddAsync(pharmacyHead); 57 await _context.SaveChangesAsync(); 58 } 59 60 public async Task Remove(PharmacyHead phead) 61 { 62 var Phead = await _context.PharmacyHeads.Where(x => x.Id == phead.Id).FirstOrDefaultAsync(); 63 Phead.DeletedOn = phead.DeletedOn; 64 await _context.SaveChangesAsync(); 65 } 66 67 public async Task RemoveClaimingRequest(int id) 68 { 69 var req = await _context.PHRequests.Where(r => r.Id == id).FirstOrDefaultAsync(); 70 _context.PHRequests.Remove(req); 71 await _context.SaveChangesAsync(); 72 } 47 73 } 48 74 } -
FarmatikoData/FarmatikoRepo/Repository.cs
r1454207 r6f203af 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore; 4 using System; 5 using System.Collections.Generic; 3 6 using System.Linq; 4 7 using System.Threading.Tasks; … … 14 17 } 15 18 //GET 16 public async Task<I Queryable<HealthcareWorker>> GetAllWorkers()19 public async Task<IEnumerable<HealthcareWorker>> GetAllWorkers() 17 20 { 18 21 var Workers = await Task.Run(() => _context.HealthcareWorkers.Take(10)); … … 20 23 } 21 24 22 public async Task<I Queryable<HealthFacility>> GetFacilities()25 public async Task<IEnumerable<HealthFacility>> GetFacilities() 23 26 { 24 27 var Facilities = await Task.Run(() => _context.HealthFacilities.Take(10)); … … 38 41 } 39 42 40 public async Task<I Queryable<Medicine>> GetMedicines()43 public async Task<IEnumerable<Medicine>> GetMedicines() 41 44 { 42 45 var Medicines = await Task.Run(() => _context.Medicines.Take(10)); … … 50 53 } 51 54 52 public async Task<I Queryable<Pharmacy>> GetPharmacies()55 public async Task<IEnumerable<Pharmacy>> GetPharmacies() 53 56 { 54 57 var Pharmacies = await Task.Run(() => _context.Pharmacies.Take(10)); … … 68 71 } 69 72 70 public async Task<I Queryable<HealthFacility>> SearchFacilities(string query)73 public async Task<IEnumerable<HealthFacility>> SearchFacilities(string query) 71 74 { 72 75 var SearchQuery = await Task.Run(() => _context.HealthFacilities … … 77 80 } 78 81 79 public async Task<I Queryable<Medicine>> SearchMedicines(string query)82 public async Task<IEnumerable<Medicine>> SearchMedicines(string query) 80 83 { 81 84 var SearchQuery = await Task.Run(() => _context.Medicines … … 86 89 } 87 90 88 public async Task<I Queryable<Pharmacy>> SearchPharmacies(string query)91 public async Task<IEnumerable<Pharmacy>> SearchPharmacies(string query) 89 92 { 90 93 var SearchQuery = await Task.Run(() => _context.Pharmacies … … 95 98 } 96 99 97 public async Task<I Queryable<HealthcareWorker>> SearchWorkers(string query)100 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query) 98 101 { 99 102 var SearchQuery = await Task.Run(() => _context.HealthcareWorkers … … 184 187 await _context.SaveChangesAsync(); 185 188 } 186 // ke vidime189 //not impl 187 190 public Task UpdateWorker(HealthcareWorker worker) 188 191 { … … 205 208 } 206 209 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;210 public async Task RemovePharmacyHead(int Id) 211 { 212 var PHead = await _context.PharmacyHeads.Where(x => x.Id == Id).FirstOrDefaultAsync(); 213 PHead.DeletedOn = DateTime.UtcNow; 211 214 await _context.SaveChangesAsync(); 212 215 } -
FarmatikoData/FarmatikoRepoInterfaces/IAdminRepo.cs
r1454207 r6f203af 10 10 public interface IAdminRepo 11 11 { 12 Task<I Queryable<RequestPharmacyHead>> GetClaimingRequests();13 Task<I Queryable<PharmacyHead>> GetPharmacyHeads();14 TaskRemoveClaimRequest(RequestPharmacyHead req);12 Task<IEnumerable<RequestPharmacyHead>> GetClaimingRequests(); 13 Task<IEnumerable<PharmacyHead>> GetPharmacyHeads(); 14 void RemoveClaimRequest(RequestPharmacyHead req); 15 15 } 16 16 } -
FarmatikoData/FarmatikoRepoInterfaces/IPHRepo.cs
r1454207 r6f203af 11 11 { 12 12 Task ClaimPharmacy(RequestPharmacyHead pharmacy); 13 Task<PharmacyHead> GetPharmacyHead(PharmacyHead pharmacyHead); 14 Task<IQueryable<PharmacyHead>> GetPharmacyHeadInfo(); 13 Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo(); 15 14 Task UpdatePharmacyHead(PharmacyHead pharmacyHead); 15 Task<PharmacyHead> GetPharmacyHeadByIdAsync(int id); 16 Task Add(PharmacyHead pharmacyHead); 17 Task Remove(PharmacyHead phead); 18 Task RemoveClaimingRequest(int id); 16 19 } 17 20 } -
FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs
r1454207 r6f203af 11 11 { 12 12 //GET 13 Task<I Queryable<HealthcareWorker>> GetAllWorkers();14 Task<I Queryable<HealthFacility>> GetFacilities();13 Task<IEnumerable<HealthcareWorker>> GetAllWorkers(); 14 Task<IEnumerable<HealthFacility>> GetFacilities(); 15 15 Task<HealthFacility> GetFacility(int Id); 16 16 Task<Medicine> GetMedicine(int Id); 17 Task<I Queryable<Medicine>> GetMedicines();17 Task<IEnumerable<Medicine>> GetMedicines(); 18 18 Task<Pandemic> GetPandemic(); 19 Task<I Queryable<Pharmacy>> GetPharmacies();19 Task<IEnumerable<Pharmacy>> GetPharmacies(); 20 20 Task<Pharmacy> GetPharmacy(int id); 21 21 Task<HealthcareWorker> GetWorker(int id); 22 Task<I Queryable<HealthFacility>> SearchFacilities(string query);23 Task<I Queryable<Medicine>> SearchMedicines(string query);24 Task<I Queryable<Pharmacy>> SearchPharmacies(string query);25 Task<I Queryable<HealthcareWorker>> SearchWorkers(string query);22 Task<IEnumerable<HealthFacility>> SearchFacilities(string query); 23 Task<IEnumerable<Medicine>> SearchMedicines(string query); 24 Task<IEnumerable<Pharmacy>> SearchPharmacies(string query); 25 Task<IEnumerable<HealthcareWorker>> SearchWorkers(string query); 26 26 Task<HealthFacility> GetFacilityJSON(string healthFacility); 27 27 … … 40 40 Task UpadatePharmacy(Pharmacy pharmacy); 41 41 Task UpdateMedicine(Medicine medicine); 42 Task RemovePharmacyHead( PharmacyHead pharmacyHead);42 Task RemovePharmacyHead(int Id); 43 43 } 44 44 } -
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.