[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();
|
---|
[f554983] | 28 | //await _JSONservice.GetProcessedHealthFacilitiesFromJSON();
|
---|
| 29 | //await _JSONservice.GetProcessedMedicinesFromJSON();
|
---|
[d23bf72] | 30 | }
|
---|
| 31 | [HttpGet]
|
---|
[6f203af] | 32 | [Route("api/workers")]
|
---|
| 33 | public async Task<IEnumerable<HealthcareWorker>> GetWorkers()
|
---|
[5d02859] | 34 | {
|
---|
[1454207] | 35 | var Workers = await _service.GetAllWorkers();
|
---|
| 36 | return Workers;
|
---|
[5d02859] | 37 | }
|
---|
| 38 | [HttpGet]
|
---|
[d23bf72] | 39 | [Route("api/workers/search/{query}")]
|
---|
| 40 | public async Task<IEnumerable<HealthcareWorker>> SearchWorkers([FromRoute]string query)
|
---|
[5d02859] | 41 | {
|
---|
[d23bf72] | 42 | return await _service.SearchWorkers(query);
|
---|
[5d02859] | 43 | }
|
---|
| 44 | [HttpGet]
|
---|
[6f203af] | 45 | [Route("api/workers/{id}")]
|
---|
[d23bf72] | 46 | public async Task<HealthcareWorker> GetWorker([FromRoute] int Id)
|
---|
[5d02859] | 47 | {
|
---|
| 48 | return await _service.GetWorker(Id);
|
---|
| 49 | }
|
---|
| 50 | //Post
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | //Facilities
|
---|
| 54 | //Get
|
---|
| 55 | [HttpGet]
|
---|
[6f203af] | 56 | [Route("api/facilities")]
|
---|
| 57 | public async Task<IEnumerable<HealthFacility>> GetFacilities()
|
---|
[5d02859] | 58 | {
|
---|
| 59 | return await _service.GetFacilities();
|
---|
| 60 | }
|
---|
| 61 | [HttpGet]
|
---|
[d23bf72] | 62 | [Route("api/facilities/search/{query}")]
|
---|
| 63 | public async Task<IEnumerable<HealthFacility>> SearchFacilities([FromRoute] string query)
|
---|
[5d02859] | 64 | {
|
---|
[d23bf72] | 65 | return await _service.SearchFacilities(query);
|
---|
[5d02859] | 66 | }
|
---|
| 67 | [HttpGet]
|
---|
[d23bf72] | 68 | [Route("api/facilities/{id}")]
|
---|
| 69 | public async Task<HealthFacility> GetFacility([FromRoute] int id)
|
---|
[5d02859] | 70 | {
|
---|
[d23bf72] | 71 | return await _service.GetFacility(id);
|
---|
[5d02859] | 72 | }
|
---|
| 73 | //Post
|
---|
| 74 |
|
---|
| 75 | //Medicine
|
---|
| 76 | //Get
|
---|
| 77 | [HttpGet]
|
---|
[6f203af] | 78 | [Route("api/medicines")]
|
---|
[afefe75] | 79 | public async Task<IEnumerable<MedicineDTO>> GetMedicines()
|
---|
[5d02859] | 80 | {
|
---|
| 81 | return await _service.GetMedicines();
|
---|
| 82 | }
|
---|
| 83 | [HttpGet]
|
---|
[d23bf72] | 84 | [Route("api/medicines/search/{query}")]
|
---|
[e0cdea2] | 85 | public async Task<IEnumerable<MedicineDTO>> SearchMedicines([FromRoute] string query)
|
---|
[5d02859] | 86 | {
|
---|
[d23bf72] | 87 | return await _service.SearchMedicines(query);
|
---|
[5d02859] | 88 | }
|
---|
| 89 | [HttpGet]
|
---|
[6f203af] | 90 | [Route("api/medicines/{Id}")]
|
---|
[d23bf72] | 91 | public async Task<Medicine> GetMedicine([FromRoute] int Id)
|
---|
[5d02859] | 92 | {
|
---|
| 93 | return await _service.GetMedicine(Id);
|
---|
| 94 | }
|
---|
| 95 | //Pandemic
|
---|
| 96 | [HttpGet]
|
---|
[6f203af] | 97 | [Route("api/pandemic")]
|
---|
[e0cdea2] | 98 | public Pandemic GetPandemic()
|
---|
[5d02859] | 99 | {
|
---|
[e0cdea2] | 100 | return _service.GetPandemic();
|
---|
[5d02859] | 101 | }
|
---|
| 102 | //Pharmacy
|
---|
| 103 | //GET
|
---|
| 104 | [HttpGet]
|
---|
[6f203af] | 105 | [Route("api/pharmacy")]
|
---|
[afefe75] | 106 | public async Task<IEnumerable<PharmacyDTO>> GetPharmacies()
|
---|
[5d02859] | 107 | {
|
---|
| 108 | return await _service.GetPharmacies();
|
---|
| 109 | }
|
---|
| 110 | [HttpGet]
|
---|
[6f203af] | 111 | [Route("api/pharmacy/search/{Query}")]
|
---|
[e0cdea2] | 112 | public async Task<IEnumerable<PharmacyDTO>> SearchPharmacies([FromRoute] string Query)
|
---|
[5d02859] | 113 | {
|
---|
| 114 | return await _service.SearchPharmacies(Query);
|
---|
| 115 | }
|
---|
| 116 | [HttpGet]
|
---|
[6f203af] | 117 | [Route("api/pharmacy/{Id}")]
|
---|
[d23bf72] | 118 | public async Task<Pharmacy> GetPharmacy([FromRoute] int Id)
|
---|
[5d02859] | 119 | {
|
---|
| 120 | return await _service.GetPharmacy(Id);
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | }
|
---|
| 124 | }
|
---|