[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]
|
---|
[d23bf72] | 11 | [Authorize(Roles = "PharmacyHead")]
|
---|
[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
|
---|
[d23bf72] | 21 | /*[HttpGet]
|
---|
[6f203af] | 22 | [Route("api/pharmacyhead")]
|
---|
[d23bf72] | 23 | public async Task<IEnumerable<PharmacyHead>> GetPharmacyHeadInfo()
|
---|
[6f203af] | 24 | {
|
---|
[d23bf72] | 25 | var PHeads = await _PHService.GetPharmacyHeadInfo();
|
---|
[6f203af] | 26 | return PHeads;
|
---|
[d23bf72] | 27 | }*/
|
---|
[6f203af] | 28 | [HttpGet]
|
---|
| 29 | [Route("api/pharmacyhead/{Id}")]
|
---|
[d23bf72] | 30 | public async Task<PharmacyHead> GetPharmacyHeadById([FromRoute]int Id)
|
---|
[4e72684] | 31 | {
|
---|
[6f203af] | 32 | var Phead = await _PHService.GetPharmacyHeadByIdAsync(Id);
|
---|
| 33 | return Phead;
|
---|
[4e72684] | 34 | }
|
---|
[1454207] | 35 | //POST
|
---|
| 36 | [HttpPost]
|
---|
[6f203af] | 37 | [Route("api/pharmacyhead/add")]
|
---|
[d23bf72] | 38 | public async Task<IActionResult> AddPharmacyHead([FromBody]PharmacyHead pharmacyHead)
|
---|
[a55ef91] | 39 | {
|
---|
[6f203af] | 40 | bool Success = await _PHService.Add(pharmacyHead);
|
---|
| 41 | return Ok(Success);
|
---|
[a55ef91] | 42 | }
|
---|
[6f203af] | 43 |
|
---|
[d23bf72] | 44 | /*[HttpPost]
|
---|
[6f203af] | 45 | [Route("api/pharmacyhead/login")]
|
---|
| 46 | public async Task<int> Login([FromBody]PharmacyHead pharmacyHead)
|
---|
| 47 | {
|
---|
| 48 | return await _PHService.Login(pharmacyHead);
|
---|
[d23bf72] | 49 | }*/
|
---|
[6f203af] | 50 | [HttpPut]
|
---|
| 51 | [Route("api/pharmacyhead/{Id}")]
|
---|
| 52 | public async Task UpdatePharmacyHead([FromBody]PharmacyHead pharmacyHead)
|
---|
[a55ef91] | 53 | {
|
---|
[1454207] | 54 | await _PHService.UpdatePharmacyHead(pharmacyHead);
|
---|
[a55ef91] | 55 | }
|
---|
| 56 | [HttpPost]
|
---|
[6f203af] | 57 | [Route("api/pharmacyhead/requests")]
|
---|
[d23bf72] | 58 | public async Task<IActionResult> ClaimPharmacy([FromBody]RequestPharmacyHead pharmacy)
|
---|
[a55ef91] | 59 | {
|
---|
[6f203af] | 60 | bool Success = await _PHService.ClaimPharmacy(pharmacy);
|
---|
| 61 | return Ok(Success);
|
---|
| 62 | }
|
---|
| 63 | [HttpDelete]
|
---|
| 64 | [Route("api/pharmacyhead/delete/{Id}")]
|
---|
[d23bf72] | 65 | public async Task<IActionResult> Remove([FromRoute] int Id)
|
---|
[6f203af] | 66 | {
|
---|
| 67 | bool Success = await _PHService.Remove(Id);
|
---|
| 68 | return Ok(Success);
|
---|
| 69 | }
|
---|
| 70 | [HttpPost]
|
---|
| 71 | [Route("api/pharmacyhead/requests/{Id}")]
|
---|
[d23bf72] | 72 | public async Task<IActionResult> RemoveClaimingRequest([FromRoute] int Id)
|
---|
[6f203af] | 73 | {
|
---|
| 74 | bool Success = await _PHService.RemoveClaimingRequest(Id);
|
---|
| 75 | return Ok(Success);
|
---|
[a55ef91] | 76 | }
|
---|
[1454207] | 77 |
|
---|
[4e72684] | 78 | }
|
---|
| 79 | }
|
---|