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