[d23bf72] | 1 | using System.Collections.Generic;
|
---|
[1454207] | 2 | using System.Threading.Tasks;
|
---|
[4e72684] | 3 | using FarmatikoData.Models;
|
---|
[1454207] | 4 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
[d23bf72] | 5 | using Microsoft.AspNetCore.Authorization;
|
---|
[4e72684] | 6 | using Microsoft.AspNetCore.Mvc;
|
---|
| 7 |
|
---|
| 8 | namespace Farmatiko.Controllers
|
---|
| 9 | {
|
---|
| 10 | [ApiController]
|
---|
[68454c6] | 11 | [Authorize(Roles = "PharmacyHead,Admin")]
|
---|
[4e72684] | 12 | public class PharmacyHeadController : Controller
|
---|
| 13 | {
|
---|
[1454207] | 14 | private readonly IPHService _PHService;
|
---|
| 15 | public PharmacyHeadController(IPHService PHService)
|
---|
[4e72684] | 16 | {
|
---|
[1454207] | 17 | _PHService = PHService;
|
---|
[4e72684] | 18 | }
|
---|
[6f203af] | 19 |
|
---|
[1454207] | 20 | //GET
|
---|
[1db5673] | 21 | /*
|
---|
| 22 | [HttpGet]
|
---|
[6f203af] | 23 | [Route("api/pharmacyhead")]
|
---|
[d23bf72] | 24 | public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo()
|
---|
[6f203af] | 25 | {
|
---|
[d23bf72] | 26 | var PHeads = await _PHService.GetPharmacyHeadInfo();
|
---|
[6f203af] | 27 | return PHeads;
|
---|
[d23bf72] | 28 | }*/
|
---|
[1db5673] | 29 |
|
---|
[6f203af] | 30 | [HttpGet]
|
---|
| 31 | [Route("api/pharmacyhead/{Id}")]
|
---|
[d23bf72] | 32 | public async Task<PharmacyHead> GetPharmacyHeadById([FromRoute]int Id)
|
---|
[4e72684] | 33 | {
|
---|
[6f203af] | 34 | var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id);
|
---|
| 35 | return Phead;
|
---|
[4e72684] | 36 | }
|
---|
[1454207] | 37 | //POST
|
---|
[68454c6] | 38 | /*
|
---|
[1454207] | 39 | [HttpPost]
|
---|
[6f203af] | 40 | [Route("api/pharmacyhead/add")]
|
---|
[68454c6] | 41 | public async Task<IActionResult> AddPharmacyHead([FromBody] PharmacyHead pharmacyHead)
|
---|
[a55ef91] | 42 | {
|
---|
[6f203af] | 43 | bool Success = await _PHService.Add(pharmacyHead);
|
---|
| 44 | return Ok(Success);
|
---|
[1db5673] | 45 | }*/
|
---|
[6f203af] | 46 |
|
---|
[d23bf72] | 47 | /*[HttpPost]
|
---|
[6f203af] | 48 | [Route("api/pharmacyhead/login")]
|
---|
| 49 | public async Task<int> Login([FromBody]PharmacyHead pharmacyHead)
|
---|
| 50 | {
|
---|
| 51 | return await _PHService.Login(pharmacyHead);
|
---|
[d23bf72] | 52 | }*/
|
---|
[6f203af] | 53 | [HttpPut]
|
---|
[68454c6] | 54 | [Route("api/pharmacyhead/update")]
|
---|
[6f203af] | 55 | public async Task UpdatePharmacyHead([FromBody]PharmacyHead pharmacyHead)
|
---|
[a55ef91] | 56 | {
|
---|
[1454207] | 57 | await _PHService.UpdatePharmacyHead(pharmacyHead);
|
---|
[a55ef91] | 58 | }
|
---|
| 59 | [HttpPost]
|
---|
[6f203af] | 60 | [Route("api/pharmacyhead/requests")]
|
---|
[d23bf72] | 61 | public async Task<IActionResult> ClaimPharmacy([FromBody]RequestPharmacyHead pharmacy)
|
---|
[a55ef91] | 62 | {
|
---|
[6f203af] | 63 | bool Success = await _PHService.ClaimPharmacy(pharmacy);
|
---|
| 64 | return Ok(Success);
|
---|
| 65 | }
|
---|
| 66 | [HttpDelete]
|
---|
| 67 | [Route("api/pharmacyhead/delete/{Id}")]
|
---|
[d23bf72] | 68 | public async Task<IActionResult> Remove([FromRoute] int Id)
|
---|
[6f203af] | 69 | {
|
---|
| 70 | bool Success = await _PHService.Remove(Id);
|
---|
| 71 | return Ok(Success);
|
---|
| 72 | }
|
---|
| 73 | [HttpPost]
|
---|
| 74 | [Route("api/pharmacyhead/requests/{Id}")]
|
---|
[d23bf72] | 75 | public async Task<IActionResult> RemoveClaimingRequest([FromRoute] int Id)
|
---|
[6f203af] | 76 | {
|
---|
| 77 | bool Success = await _PHService.RemoveClaimingRequest(Id);
|
---|
| 78 | return Ok(Success);
|
---|
[a55ef91] | 79 | }
|
---|
[1454207] | 80 |
|
---|
[4e72684] | 81 | }
|
---|
| 82 | }
|
---|