[6f203af] | 1 | using System.Collections.Generic;
|
---|
[5d02859] | 2 | using System.Threading.Tasks;
|
---|
[afefe75] | 3 | using FarmatikoData.DTOs;
|
---|
[5d02859] | 4 | using FarmatikoData.Models;
|
---|
| 5 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
| 6 | using Microsoft.AspNetCore.Mvc;
|
---|
| 7 |
|
---|
| 8 | namespace Farmatiko.Controllers
|
---|
| 9 | {
|
---|
| 10 | [ApiController]
|
---|
| 11 | public class FarmatikoController : Controller
|
---|
| 12 | {
|
---|
| 13 | private readonly IService _service;
|
---|
[d23bf72] | 14 | private readonly IProcessJSONService _JSONservice;
|
---|
| 15 | public FarmatikoController(IService service, IProcessJSONService JSONservice)
|
---|
[5d02859] | 16 | {
|
---|
| 17 | _service = service;
|
---|
[d23bf72] | 18 | _JSONservice = JSONservice;
|
---|
[5d02859] | 19 | }
|
---|
| 20 | // Workers
|
---|
| 21 | //Get
|
---|
| 22 | [HttpGet]
|
---|
[d23bf72] | 23 | [Route("api/getData")]
|
---|
| 24 | public void InsertData()
|
---|
| 25 | {
|
---|
| 26 | //_JSONservice.DownloadPharmaciesExcel();
|
---|
[db484c9] | 27 | //_JSONservice.GetProcessedHealthcareWorkersFromJSON();
|
---|
[d23bf72] | 28 | //_JSONservice.GetProcessedHealthFacilitiesFromJSON();
|
---|
| 29 | //_JSONservice.GetProcessedMedicinesFromJSON();
|
---|
[8e74e2f] | 30 | //_JSONservice.GetProcessedPandemicsFromJSONApi();
|
---|
[d23bf72] | 31 | }
|
---|
| 32 | [HttpGet]
|
---|
[6f203af] | 33 | [Route("api/workers")]
|
---|
| 34 | public async Task<IEnumerable<HealthcareWorker>> GetWorkers()
|
---|
[5d02859] | 35 | {
|
---|
[1454207] | 36 | var Workers = await _service.GetAllWorkers();
|
---|
| 37 | return Workers;
|
---|
[5d02859] | 38 | }
|
---|
| 39 | [HttpGet]
|
---|
[d23bf72] | 40 | [Route("api/workers/search/{query}")]
|
---|
| 41 | public async Task<IEnumerable<HealthcareWorker>> SearchWorkers([FromRoute]string query)
|
---|
[5d02859] | 42 | {
|
---|
[d23bf72] | 43 | return await _service.SearchWorkers(query);
|
---|
[5d02859] | 44 | }
|
---|
| 45 | [HttpGet]
|
---|
[6f203af] | 46 | [Route("api/workers/{id}")]
|
---|
[d23bf72] | 47 | public async Task<HealthcareWorker> GetWorker([FromRoute] int Id)
|
---|
[5d02859] | 48 | {
|
---|
| 49 | return await _service.GetWorker(Id);
|
---|
| 50 | }
|
---|
| 51 | //Post
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | //Facilities
|
---|
| 55 | //Get
|
---|
| 56 | [HttpGet]
|
---|
[6f203af] | 57 | [Route("api/facilities")]
|
---|
| 58 | public async Task<IEnumerable<HealthFacility>> GetFacilities()
|
---|
[5d02859] | 59 | {
|
---|
| 60 | return await _service.GetFacilities();
|
---|
| 61 | }
|
---|
| 62 | [HttpGet]
|
---|
[d23bf72] | 63 | [Route("api/facilities/search/{query}")]
|
---|
| 64 | public async Task<IEnumerable<HealthFacility>> SearchFacilities([FromRoute] string query)
|
---|
[5d02859] | 65 | {
|
---|
[d23bf72] | 66 | return await _service.SearchFacilities(query);
|
---|
[5d02859] | 67 | }
|
---|
| 68 | [HttpGet]
|
---|
[d23bf72] | 69 | [Route("api/facilities/{id}")]
|
---|
| 70 | public async Task<HealthFacility> GetFacility([FromRoute] int id)
|
---|
[5d02859] | 71 | {
|
---|
[d23bf72] | 72 | return await _service.GetFacility(id);
|
---|
[5d02859] | 73 | }
|
---|
| 74 | //Post
|
---|
| 75 |
|
---|
| 76 | //Medicine
|
---|
| 77 | //Get
|
---|
| 78 | [HttpGet]
|
---|
[6f203af] | 79 | [Route("api/medicines")]
|
---|
[afefe75] | 80 | public async Task<IEnumerable<MedicineDTO>> GetMedicines()
|
---|
[5d02859] | 81 | {
|
---|
| 82 | return await _service.GetMedicines();
|
---|
| 83 | }
|
---|
| 84 | [HttpGet]
|
---|
[d23bf72] | 85 | [Route("api/medicines/search/{query}")]
|
---|
[e0cdea2] | 86 | public async Task<IEnumerable<MedicineDTO>> SearchMedicines([FromRoute] string query)
|
---|
[5d02859] | 87 | {
|
---|
[d23bf72] | 88 | return await _service.SearchMedicines(query);
|
---|
[5d02859] | 89 | }
|
---|
| 90 | [HttpGet]
|
---|
[6f203af] | 91 | [Route("api/medicines/{Id}")]
|
---|
[d23bf72] | 92 | public async Task<Medicine> GetMedicine([FromRoute] int Id)
|
---|
[5d02859] | 93 | {
|
---|
| 94 | return await _service.GetMedicine(Id);
|
---|
| 95 | }
|
---|
| 96 | //Pandemic
|
---|
| 97 | [HttpGet]
|
---|
[6f203af] | 98 | [Route("api/pandemic")]
|
---|
[e0cdea2] | 99 | public Pandemic GetPandemic()
|
---|
[5d02859] | 100 | {
|
---|
[e0cdea2] | 101 | return _service.GetPandemic();
|
---|
[5d02859] | 102 | }
|
---|
| 103 | //Pharmacy
|
---|
| 104 | //GET
|
---|
| 105 | [HttpGet]
|
---|
[6f203af] | 106 | [Route("api/pharmacy")]
|
---|
[afefe75] | 107 | public async Task<IEnumerable<PharmacyDTO>> GetPharmacies()
|
---|
[5d02859] | 108 | {
|
---|
| 109 | return await _service.GetPharmacies();
|
---|
| 110 | }
|
---|
| 111 | [HttpGet]
|
---|
[6f203af] | 112 | [Route("api/pharmacy/search/{Query}")]
|
---|
[e0cdea2] | 113 | public async Task<IEnumerable<PharmacyDTO>> SearchPharmacies([FromRoute] string Query)
|
---|
[5d02859] | 114 | {
|
---|
| 115 | return await _service.SearchPharmacies(Query);
|
---|
| 116 | }
|
---|
| 117 | [HttpGet]
|
---|
[6f203af] | 118 | [Route("api/pharmacy/{Id}")]
|
---|
[d23bf72] | 119 | public async Task<Pharmacy> GetPharmacy([FromRoute] int Id)
|
---|
[5d02859] | 120 | {
|
---|
| 121 | return await _service.GetPharmacy(Id);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | }
|
---|
| 125 | }
|
---|