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