source: Farmatiko/Controllers/FarmatikoController.cs@ 1454207

Last change on this file since 1454207 was 1454207, checked in by DimitarSlezenkovski <dslezenkovski@…>, 2 years ago

Change structure, Add repo, services & controllers

  • Property mode set to 100644
File size: 3.2 KB
Line 
1using System.Linq;
2using System.Threading.Tasks;
3using FarmatikoData.Models;
4using FarmatikoServices.FarmatikoServiceInterfaces;
5using Microsoft.AspNetCore.Mvc;
6
7namespace 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")]
22 public async Task<IQueryable<HealthcareWorker>> GetWorkers()
23 {
24 var Workers = await _service.GetAllWorkers();
25 return Workers;
26 }
27 [HttpGet]
28 [Route("/api/workers/search/{Query}")]
29 public async Task<IQueryable<HealthcareWorker>> SearchWorkers(string Query)
30 {
31 return await _service.SearchWorkers(Query);
32 }
33 [HttpGet]
34 [Route("/api/workers/{id}")]
35 public async Task<HealthcareWorker> GetWorker(int Id)
36 {
37 return await _service.GetWorker(Id);
38 }
39 //Post
40
41
42 //Facilities
43 //Get
44 [HttpGet]
45 [Route("/api/facilities")]
46 public async Task<IQueryable<HealthFacility>> GetFacilities()
47 {
48 return await _service.GetFacilities();
49 }
50 [HttpGet]
51 [Route("/api/facilities/search/{Query}")]
52 public async Task<IQueryable<HealthFacility>> SearchFacilities(string Query)
53 {
54 return await _service.SearchFacilities(Query);
55 }
56 [HttpGet]
57 [Route("/api/facilities/{Id}")]
58 public async Task<HealthFacility> GetFacility(int Id)
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}
Note: See TracBrowser for help on using the repository browser.