1 | using System.Collections.Generic;
|
---|
2 | using System.Threading.Tasks;
|
---|
3 | using FarmatikoData.DTOs;
|
---|
4 | using FarmatikoData.Models;
|
---|
5 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
6 | using Microsoft.AspNetCore.Authorization;
|
---|
7 | using Microsoft.AspNetCore.Mvc;
|
---|
8 |
|
---|
9 | namespace Farmatiko.Controllers
|
---|
10 | {
|
---|
11 | [ApiController]
|
---|
12 | [Authorize(Roles = "PharmacyHead,Admin")]
|
---|
13 | public class PharmacyHeadController : Controller
|
---|
14 | {
|
---|
15 | private readonly IPHService _PHService;
|
---|
16 | public PharmacyHeadController(IPHService PHService)
|
---|
17 | {
|
---|
18 | _PHService = PHService;
|
---|
19 | }
|
---|
20 |
|
---|
21 | //GET
|
---|
22 |
|
---|
23 | [HttpGet]
|
---|
24 | [Route("api/pharmacyhead/{Id}")]
|
---|
25 | public async Task<PharmacyHead> GetPharmacyHeadById([FromRoute] int Id)
|
---|
26 | {
|
---|
27 | var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id);
|
---|
28 | return Phead;
|
---|
29 | }
|
---|
30 | //POST
|
---|
31 |
|
---|
32 | [HttpPut]
|
---|
33 | [Route("api/pharmacyhead/update")]
|
---|
34 | public async Task<IActionResult> UpdatePharmacyHead([FromBody] PharmacyHeadDto pharmacyHead)
|
---|
35 | {
|
---|
36 | await _PHService.UpdatePharmacyHead(pharmacyHead);
|
---|
37 | return Ok();
|
---|
38 | }
|
---|
39 | [HttpPost]
|
---|
40 | [Route("api/pharmacyhead/requests")]
|
---|
41 | public async Task<IActionResult> ClaimPharmacy([FromBody] RequestPharmacyHead pharmacy)
|
---|
42 | {
|
---|
43 | bool Success = await _PHService.ClaimPharmacy(pharmacy);
|
---|
44 | return Ok(Success);
|
---|
45 | }
|
---|
46 | [HttpDelete]
|
---|
47 | [Route("api/pharmacyhead/delete/{Id}")]
|
---|
48 | public async Task<IActionResult> Remove([FromRoute] int Id)
|
---|
49 | {
|
---|
50 | bool Success = await _PHService.Remove(Id);
|
---|
51 | return Ok(Success);
|
---|
52 | }
|
---|
53 | [HttpPost]
|
---|
54 | [Route("api/pharmacyhead/requests/{Id}")]
|
---|
55 | public async Task<IActionResult> RemoveClaimingRequest([FromRoute] int Id)
|
---|
56 | {
|
---|
57 | bool Success = await _PHService.RemoveClaimingRequest(Id);
|
---|
58 | return Ok(Success);
|
---|
59 | }
|
---|
60 |
|
---|
61 | }
|
---|
62 | }
|
---|