source: Farmatiko/Controllers/FarmatikoController.cs@ dae4cde

Last change on this file since dae4cde was e0cdea2, checked in by Dimitar Slezenkovski <dslezenkovski@…>, 4 years ago

Fix all bugs

  • Property mode set to 100644
File size: 3.8 KB
Line 
1using System.Collections.Generic;
2using System.Threading.Tasks;
3using FarmatikoData.DTOs;
4using FarmatikoData.Models;
5using FarmatikoServices.FarmatikoServiceInterfaces;
6using Microsoft.AspNetCore.Mvc;
7
8namespace 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 //_JSONservice.GetProcessedHealthFacilitiesFromJSON();
29 //_JSONservice.GetProcessedMedicinesFromJSON();
30 //_JSONservice.GetProcessedPandemicsFromJSONApi();
31 }
32 [HttpGet]
33 [Route("api/workers")]
34 public async Task<IEnumerable<HealthcareWorker>> GetWorkers()
35 {
36 var Workers = await _service.GetAllWorkers();
37 return Workers;
38 }
39 [HttpGet]
40 [Route("api/workers/search/{query}")]
41 public async Task<IEnumerable<HealthcareWorker>> SearchWorkers([FromRoute]string query)
42 {
43 return await _service.SearchWorkers(query);
44 }
45 [HttpGet]
46 [Route("api/workers/{id}")]
47 public async Task<HealthcareWorker> GetWorker([FromRoute] int Id)
48 {
49 return await _service.GetWorker(Id);
50 }
51 //Post
52
53
54 //Facilities
55 //Get
56 [HttpGet]
57 [Route("api/facilities")]
58 public async Task<IEnumerable<HealthFacility>> GetFacilities()
59 {
60 return await _service.GetFacilities();
61 }
62 [HttpGet]
63 [Route("api/facilities/search/{query}")]
64 public async Task<IEnumerable<HealthFacility>> SearchFacilities([FromRoute] string query)
65 {
66 return await _service.SearchFacilities(query);
67 }
68 [HttpGet]
69 [Route("api/facilities/{id}")]
70 public async Task<HealthFacility> GetFacility([FromRoute] int id)
71 {
72 return await _service.GetFacility(id);
73 }
74 //Post
75
76 //Medicine
77 //Get
78 [HttpGet]
79 [Route("api/medicines")]
80 public async Task<IEnumerable<MedicineDTO>> GetMedicines()
81 {
82 return await _service.GetMedicines();
83 }
84 [HttpGet]
85 [Route("api/medicines/search/{query}")]
86 public async Task<IEnumerable<MedicineDTO>> SearchMedicines([FromRoute] string query)
87 {
88 return await _service.SearchMedicines(query);
89 }
90 [HttpGet]
91 [Route("api/medicines/{Id}")]
92 public async Task<Medicine> GetMedicine([FromRoute] int Id)
93 {
94 return await _service.GetMedicine(Id);
95 }
96 //Pandemic
97 [HttpGet]
98 [Route("api/pandemic")]
99 public Pandemic GetPandemic()
100 {
101 return _service.GetPandemic();
102 }
103 //Pharmacy
104 //GET
105 [HttpGet]
106 [Route("api/pharmacy")]
107 public async Task<IEnumerable<PharmacyDTO>> GetPharmacies()
108 {
109 return await _service.GetPharmacies();
110 }
111 [HttpGet]
112 [Route("api/pharmacy/search/{Query}")]
113 public async Task<IEnumerable<PharmacyDTO>> SearchPharmacies([FromRoute] string Query)
114 {
115 return await _service.SearchPharmacies(Query);
116 }
117 [HttpGet]
118 [Route("api/pharmacy/{Id}")]
119 public async Task<Pharmacy> GetPharmacy([FromRoute] int Id)
120 {
121 return await _service.GetPharmacy(Id);
122 }
123
124 }
125}
Note: See TracBrowser for help on using the repository browser.