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