source: Farmatiko/Controllers/FarmatikoController.cs@ 1db5673

Last change on this file since 1db5673 was 1db5673, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Fix bugs, add some more

  • Property mode set to 100644
File size: 3.8 KB
Line 
1using System.Collections.Generic;
2using System.Threading.Tasks;
3using FarmatikoData.Models;
4using FarmatikoServices.FarmatikoServiceInterfaces;
5using Microsoft.AspNetCore.Mvc;
6
7namespace Farmatiko.Controllers
8{
9 [ApiController]
10 public class FarmatikoController : Controller
11 {
12 private readonly IService _service;
13 private readonly IProcessJSONService _JSONservice;
14 public FarmatikoController(IService service, IProcessJSONService JSONservice)
15 {
16 _service = service;
17 _JSONservice = JSONservice;
18 }
19 // Workers
20 //Get
21 [HttpGet]
22 [Route("api/getData")]
23 public void InsertData()
24 {
25 //_JSONservice.DownloadPharmaciesExcel();
26 //_JSONservice.GetProcessedHealthcareWorkersFromJSON();
27 //_JSONservice.GetProcessedHealthFacilitiesFromJSON();
28 //_JSONservice.GetProcessedMedicinesFromJSON();
29 _JSONservice.GetProcessedPandemicsFromJSONApi();
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<Medicine>> GetMedicines()
80 {
81 return await _service.GetMedicines();
82 }
83 [HttpGet]
84 [Route("api/medicines/search/{query}")]
85 public async Task<IEnumerable<Medicine>> 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 async Task<Pandemic> GetPandemic()
99 {
100 return await _service.GetPandemic();
101 }
102 //Pharmacy
103 //GET
104 [HttpGet]
105 [Route("api/pharmacy")]
106 public async Task<IEnumerable<Pharmacy>> GetPharmacies()
107 {
108 return await _service.GetPharmacies();
109 }
110 [HttpGet]
111 [Route("api/pharmacy/search/{Query}")]
112 public async Task<IEnumerable<Pharmacy>> 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}
Note: See TracBrowser for help on using the repository browser.